-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(form): handle exceptions in form
* Add default error boundary for form * Allow users to provide a custom error boundary
- Loading branch information
Showing
5 changed files
with
107 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Alert, Typography } from "antd"; | ||
|
||
const { ErrorBoundary } = Alert; | ||
|
||
const FormErrorBoundary = ({ children }) => ( | ||
<ErrorBoundary | ||
description={ | ||
<div style={{ whiteSpace: "normal" }}> | ||
<Typography.Text strong>Why am I getting this error?</Typography.Text> | ||
<Typography.Paragraph ellipsis={{ rows: 12, expandable: true }}> | ||
Your schema might not be following the{" "} | ||
<a | ||
href="https://json-schema.org/specification" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
JSONSchema specification | ||
</a> | ||
. This usually happens when you have manually modified the JSON schema | ||
and introduced some errors. Please make sure the schema follows the | ||
specification and try again. | ||
<br /> | ||
Notes: | ||
<ul> | ||
<li> | ||
Formule adds some custom properties to the schema not present in | ||
the JSONSchema specification, but these should not cause issues. | ||
</li> | ||
<li> | ||
When you get this error, you usually want to be looking at clear | ||
violations of the JSON Schema principles. For example, list or | ||
object fields not containing a type or containing children as | ||
direct descendants instead of within a <code>properties</code> | ||
or <code>items</code> object. | ||
</li> | ||
<li> | ||
These errors could also be coming from the uiSchema (e.g. | ||
non-existing widget/field). | ||
</li> | ||
</ul> | ||
</Typography.Paragraph> | ||
</div> | ||
} | ||
> | ||
{children} | ||
</ErrorBoundary> | ||
); | ||
|
||
export default FormErrorBoundary; |