Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-dev-overlay): accept preventDisplay prop to allow config of
which errors are display (used by next live)
- Loading branch information
Showing
5 changed files
with
67 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/react-dev-overlay/src/internal/container/RuntimeError.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/react-dev-overlay/src/internal/helpers/getErrorByType.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { TYPE_UNHANDLED_ERROR, TYPE_UNHANDLED_REJECTION } from '../bus' | ||
import { SupportedErrorEvent } from '../container/Errors' | ||
import { isNodeError } from './nodeStackFrames' | ||
import { getOriginalStackFrames, OriginalStackFrame } from './stack-frame' | ||
|
||
export type ReadyRuntimeError = { | ||
id: number | ||
runtime: true | ||
error: Error | ||
frames: OriginalStackFrame[] | ||
} | ||
|
||
export async function getErrorByType( | ||
ev: SupportedErrorEvent | ||
): Promise<ReadyRuntimeError> { | ||
const { id, event } = ev | ||
switch (event.type) { | ||
case TYPE_UNHANDLED_ERROR: | ||
case TYPE_UNHANDLED_REJECTION: { | ||
return { | ||
id, | ||
runtime: true, | ||
error: event.reason, | ||
frames: await getOriginalStackFrames( | ||
isNodeError(event.reason), | ||
event.frames | ||
), | ||
} | ||
} | ||
default: { | ||
break | ||
} | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const _: never = event | ||
throw new Error('type system invariant violation') | ||
} |