Skip to content

Commit

Permalink
Make errors in examples more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
sapegin committed Feb 19, 2021
1 parent 2cb959b commit 90fef0d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/client/rsg-components/Preview/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ interface PreviewState {
error: string | null;
}

const cleanErrorMessage = (message: string): string =>
message.replace('bound evalInContext(Example)(...): ', '');

export default class Preview extends Component<PreviewProps, PreviewState> {
public static propTypes = {
code: PropTypes.string.isRequired,
Expand Down Expand Up @@ -96,7 +99,7 @@ export default class Preview extends Component<PreviewProps, PreviewState> {
this.unmountPreview();

this.setState({
error: err.toString(),
error: cleanErrorMessage(err.toString()),
});

console.error(err); // eslint-disable-line no-console
Expand Down

0 comments on commit 90fef0d

Please sign in to comment.