Skip to content

Commit

Permalink
feat: display the stack trace when error thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
waynevanson committed Aug 28, 2023
1 parent 99f26b7 commit 3c3289c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/data-entry/src/components/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export function Application() {
});
}, [config.datasource.file.frontmatter, form, frontmatter.datasource]);

console.log({ schema, config, frontmatter });
return (
<ErrorBoundary>
{frontmatterErrors !== '' && (
Expand All @@ -114,15 +113,15 @@ export function Application() {

class ErrorBoundary extends React.Component<
{ children?: ReactNode },
{ hasError: false } | { hasError: true; error: unknown }
{ hasError: false } | { hasError: true; error: Error }
> {
constructor(props: { children?: ReactNode }) {
super(props);
this.state = { hasError: false };
}

static getDerivedStateFromError(error: unknown) {
return { hasError: true, error: error };
static getDerivedStateFromError(error: Error) {
return { hasError: true, error };
}

render() {
Expand All @@ -134,6 +133,7 @@ class ErrorBoundary extends React.Component<
<p>Please see the error that was thrown below for more information.</p>
<pre>
<code>{String(this.state.error)}</code>
<code>{this.state.error?.stack}</code>
</pre>
</div>
);
Expand Down

0 comments on commit 3c3289c

Please sign in to comment.