Skip to content

Commit

Permalink
Add error message to error boundary
Browse files Browse the repository at this point in the history
Signed-off-by: Remington Breeze <remington@breeze.software>
  • Loading branch information
rbreeze committed Sep 14, 2021
1 parent 1bc0914 commit cdaa5e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const ResourceDetails = (props: ResourceDetailsProps) => {
title: 'More',
key: 'extension',
content: (
<ErrorBoundary>
<ErrorBoundary message={`Something went wrong with Extension for ${state.kind}`}>
<ExtensionComponent tree={tree} resource={state} />
</ErrorBoundary>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';

export class ErrorBoundary extends React.Component<any, {hasError: boolean}> {
export class ErrorBoundary extends React.Component<{message?: string}, {hasError: boolean}> {
constructor(props: any) {
super(props);
this.state = {hasError: false};
Expand All @@ -12,7 +12,7 @@ export class ErrorBoundary extends React.Component<any, {hasError: boolean}> {

render() {
if (this.state.hasError) {
return <h1>Something went wrong.</h1>;
return <h1>{this.props.message ? this.props.message : 'Something went wrong.'}</h1>;
}

return this.props.children;
Expand Down

0 comments on commit cdaa5e3

Please sign in to comment.