Allow user to reset ui debugger after fatal error
Summary: Previously there was no way to get of this state Reviewed By: aigoncharov Differential Revision: D46803900 fbshipit-source-id: 2eb0eb41b58064659ef1d2cff245a2b8d7e2f261
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f9bbc967ea
commit
ae5dd80d67
@@ -7,30 +7,19 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Button, Result} from 'antd';
|
import {Result} from 'antd';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
export function StreamInterceptorErrorView({
|
export function StreamInterceptorErrorView({
|
||||||
retryCallback,
|
button,
|
||||||
title,
|
title,
|
||||||
message,
|
message,
|
||||||
}: {
|
}: {
|
||||||
title: string;
|
title: string;
|
||||||
message: string;
|
message: string;
|
||||||
retryCallback?: () => void;
|
button: React.ReactNode;
|
||||||
}): React.ReactElement {
|
}): React.ReactElement {
|
||||||
return (
|
return (
|
||||||
<Result
|
<Result status="error" title={title} subTitle={message} extra={button} />
|
||||||
status="error"
|
|
||||||
title={title}
|
|
||||||
subTitle={message}
|
|
||||||
extra={
|
|
||||||
retryCallback && (
|
|
||||||
<Button onClick={retryCallback} type="primary">
|
|
||||||
Retry
|
|
||||||
</Button>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,11 +50,16 @@ export function Component() {
|
|||||||
setBottomPanelComponent(undefined);
|
setBottomPanelComponent(undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (streamState.state === 'UnrecoverableError') {
|
if (streamState.state === 'FatalError') {
|
||||||
return (
|
return (
|
||||||
<StreamInterceptorErrorView
|
<StreamInterceptorErrorView
|
||||||
title="Oops"
|
title="Fatal Error"
|
||||||
message="Something has gone horribly wrong, we are aware of this and are looking into it"
|
message={`Something has gone horribly wrong, we are aware of this and are looking into it, details ${streamState.error.name} ${streamState.error.message}`}
|
||||||
|
button={
|
||||||
|
<Button onClick={streamState.clearCallBack} type="primary">
|
||||||
|
Reset
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -64,7 +69,11 @@ export function Component() {
|
|||||||
<StreamInterceptorErrorView
|
<StreamInterceptorErrorView
|
||||||
message={streamState.error.message}
|
message={streamState.error.message}
|
||||||
title={streamState.error.title}
|
title={streamState.error.title}
|
||||||
retryCallback={streamState.retryCallback}
|
button={
|
||||||
|
<Button onClick={streamState.retryCallback} type="primary">
|
||||||
|
Retry
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,16 @@ export function plugin(client: PluginClient<Events>) {
|
|||||||
error,
|
error,
|
||||||
);
|
);
|
||||||
|
|
||||||
uiState.streamState.set({state: 'UnrecoverableError'});
|
uiState.streamState.set({
|
||||||
|
state: 'FatalError',
|
||||||
|
error: error,
|
||||||
|
clearCallBack: async () => {
|
||||||
|
uiState.streamState.set({state: 'Ok'});
|
||||||
|
nodesAtom.set(new Map());
|
||||||
|
frameworkEvents.set(new Map());
|
||||||
|
snapshot.set(null);
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ export type StreamState =
|
|||||||
retryCallback: () => Promise<void>;
|
retryCallback: () => Promise<void>;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
state: 'UnrecoverableError';
|
state: 'FatalError';
|
||||||
|
error: Error;
|
||||||
|
clearCallBack: () => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Events = {
|
export type Events = {
|
||||||
|
|||||||
Reference in New Issue
Block a user