faasjs/faasjs

View on GitHub
packages/ant-design/src/ErrorBoundary.tsx

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { Alert } from 'antd'
import {
  ErrorBoundary as Origin,
  type ErrorBoundaryProps,
  type ErrorChildrenProps,
} from '@faasjs/react'

export type { ErrorBoundaryProps }

function ErrorChildren(props: ErrorChildrenProps) {
  return (
    <Alert
      type='error'
      message={props.errorMessage}
      description={
        <pre
          style={{
            fontSize: '0.9em',
            overflowX: 'auto',
          }}
        >
          {props.errorDescription}
        </pre>
      }
    />
  )
}

/**
 * Styled error boundary.
 */
export function ErrorBoundary(props: ErrorBoundaryProps) {
  return <Origin errorChildren={<ErrorChildren />} {...props} />
}

ErrorBoundary.whyDidYouRender = true