fix error boundary error handling

This commit is contained in:
m5r
2021-08-01 19:21:49 +08:00
parent 95488456d9
commit fdf9df243b
2 changed files with 12 additions and 12 deletions

View File

@ -60,12 +60,12 @@ type ErrorBoundaryState =
errorMessage: string;
};
const blitzErrorNames = [
RedirectError.name,
AuthenticationError.name,
AuthorizationError.name,
CSRFTokenMismatchError.name,
NotFoundError.name,
const blitzErrors = [
RedirectError,
AuthenticationError,
AuthorizationError,
CSRFTokenMismatchError,
NotFoundError,
];
const ErrorBoundary = withRouter(
@ -83,7 +83,7 @@ const ErrorBoundary = withRouter(
public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
logger.error(error, errorInfo.componentStack);
if (blitzErrorNames.includes(error.name)) {
if (blitzErrors.some((blitzError) => error instanceof blitzError)) {
// let Blitz ErrorBoundary handle this one
throw error;
}