Skip to content

Commit

Permalink
Remove ErrorBoundary onError callbacks and recovery buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Jan 30, 2023
1 parent aa9cd41 commit 1638d6a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 93 deletions.
11 changes: 2 additions & 9 deletions packages/edit-post/src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@ import { unlock } from './experiments';

const { ExperimentalEditorProvider } = unlock( editorExperiments );

function Editor( {
postId,
postType,
settings,
initialEdits,
onError,
...props
} ) {
function Editor( { postId, postType, settings, initialEdits, ...props } ) {
const {
hasFixedToolbar,
focusMode,
Expand Down Expand Up @@ -190,7 +183,7 @@ function Editor( {
__unstableTemplate={ isTemplateMode ? template : undefined }
{ ...props }
>
<ErrorBoundary onError={ onError }>
<ErrorBoundary>
<EditorInitialization postId={ postId } />
<Layout styles={ styles } />
</ErrorBoundary>
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { PluginArea } from '@wordpress/plugins';
import { Routes } from '../routes';
import Layout from '../layout';

export default function App( { onError } ) {
export default function App() {
const { createErrorNotice } = useDispatch( noticesStore );

function onPluginAreaError( name ) {
Expand All @@ -37,7 +37,7 @@ export default function App( { onError } ) {
<UnsavedChangesWarning />

<Routes>
<Layout onError={ onError } />
<Layout />
<PluginArea onError={ onPluginAreaError } />
</Routes>
</SlotFillProvider>
Expand Down
1 change: 0 additions & 1 deletion packages/edit-site/src/components/error-boundary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default class ErrorBoundary extends Component {
'The editor has encountered an unexpected error.'
) }
error={ this.state.error }
reboot={ this.props.onError }
/>
);
}
Expand Down
41 changes: 6 additions & 35 deletions packages/edit-site/src/components/error-boundary/warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,12 @@ function CopyButton( { text, children } ) {
);
}

export default function ErrorBoundaryWarning( {
message,
error,
reboot,
dashboardLink,
} ) {
const actions = [];

if ( reboot ) {
actions.push(
<Button key="recovery" onClick={ reboot } variant="secondary">
{ __( 'Attempt Recovery' ) }
</Button>
);
}

if ( error ) {
actions.push(
<CopyButton key="copy-error" text={ error.stack }>
{ __( 'Copy Error' ) }
</CopyButton>
);
}

if ( dashboardLink ) {
actions.push(
<Button
key="back-to-dashboard"
variant="secondary"
href={ dashboardLink }
>
{ __( 'Back to dashboard' ) }
</Button>
);
}
export default function ErrorBoundaryWarning( { message, error } ) {
const actions = [
<CopyButton key="copy-error" text={ error.stack }>
{ __( 'Copy Error' ) }
</CopyButton>,
];

return (
<Warning className="editor-error-boundary" actions={ actions }>
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const emptyResizeHandleStyles = {
left: undefined,
};

export default function Layout( { onError } ) {
export default function Layout() {
// This ensures the edited entity id and type are initialized properly.
useInitEditedEntityFromURL();
useSyncCanvasModeWithURL();
Expand Down Expand Up @@ -314,7 +314,7 @@ export default function Layout( { onError } ) {
ease: 'easeOut',
} }
>
<ErrorBoundary onError={ onError }>
<ErrorBoundary>
{ isEditorPage && <Editor /> }
{ isListPage && <ListPage /> }
</ErrorBoundary>
Expand Down
25 changes: 6 additions & 19 deletions packages/edit-widgets/src/components/error-boundary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,12 @@ function CopyButton( { text, children } ) {
);
}

function ErrorBoundaryWarning( { message, error, reboot } ) {
const actions = [];

if ( reboot ) {
actions.push(
<Button key="recovery" onClick={ reboot } variant="secondary">
{ __( 'Attempt Recovery' ) }
</Button>
);
}

if ( error ) {
actions.push(
<CopyButton key="copy-error" text={ error.stack }>
{ __( 'Copy Error' ) }
</CopyButton>
);
}
function ErrorBoundaryWarning( { message, error } ) {
const actions = [
<CopyButton key="copy-error" text={ error.stack }>
{ __( 'Copy Error' ) }
</CopyButton>,
];

return (
<Warning className="edit-widgets-error-boundary" actions={ actions }>
Expand Down Expand Up @@ -71,7 +59,6 @@ export default class ErrorBoundary extends Component {
'The editor has encountered an unexpected error.'
) }
error={ this.state.error }
reboot={ this.props.onError }
/>
);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-widgets/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Interface from './interface';
import UnsavedChangesWarning from './unsaved-changes-warning';
import WelcomeGuide from '../welcome-guide';

function Layout( { blockEditorSettings, onError } ) {
function Layout( { blockEditorSettings } ) {
const { createErrorNotice } = useDispatch( noticesStore );

function onPluginAreaError( name ) {
Expand All @@ -33,7 +33,7 @@ function Layout( { blockEditorSettings, onError } ) {
}

return (
<ErrorBoundary onError={ onError }>
<ErrorBoundary>
<WidgetAreasBlockEditorProvider
blockEditorSettings={ blockEditorSettings }
>
Expand Down
27 changes: 4 additions & 23 deletions packages/editor/src/components/error-boundary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class ErrorBoundary extends Component {
constructor() {
super( ...arguments );

this.getContent = this.getContent.bind( this );

this.state = {
error: null,
};
Expand All @@ -60,31 +58,14 @@ class ErrorBoundary extends Component {
return this.props.children;
}

const actions = [];

if ( this.props.onError ) {
actions.push(
<Button
key="recovery"
onClick={ this.props.onError }
variant="secondary"
>
{ __( 'Attempt Recovery' ) }
</Button>
);
}

actions.push(
const actions = [
<CopyButton key="copy-post" text={ getContent }>
{ __( 'Copy Post Text' ) }
</CopyButton>
);

actions.push(
</CopyButton>,
<CopyButton key="copy-error" text={ error.stack }>
{ __( 'Copy Error' ) }
</CopyButton>
);
</CopyButton>,
];

return (
<Warning className="editor-error-boundary" actions={ actions }>
Expand Down

0 comments on commit 1638d6a

Please sign in to comment.