"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _result = _interopRequireDefault(require("../result"));
require("./style");
var _jsxRuntime = require("react/jsx-runtime");
class WauErrorBoundary extends _react.default.Component {
  constructor(props) {
    super(props);
    this.state = {
      hasError: false,
      errorInfo: ''
    };
  }
  static getDerivedStateFromError(error) {
    return {
      hasError: true,
      errorInfo: error.message
    };
  }
  componentDidCatch(error, errorInfo) {
    // You can also log the error to an error reporting service
    // eslint-disable-next-line no-console
    console.log(error, errorInfo);
  }
  render() {
    if (this.state.hasError) {
      // You can render any custom fallback UI
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(_result.default, {
        status: "error",
        title: "Something went wrong.",
        extra: this.state.errorInfo
      });
    }
    return this.props.children;
  }
}
var _default = WauErrorBoundary;
exports.default = _default;