Buckets:
silverwolf-x/project / packages /next /src /next-devtools /userspace /app /errors /stitched-error.ts
| import React from 'react' | |
| import isError from '../../../../lib/is-error' | |
| const ownerStacks = new WeakMap<Error, string | null>() | |
| export function getOwnerStack(error: Error): string | null | undefined { | |
| return ownerStacks.get(error) | |
| } | |
| export function setOwnerStack(error: Error, stack: string | null) { | |
| ownerStacks.set(error, stack) | |
| } | |
| export function coerceError(value: unknown): Error { | |
| return isError(value) ? value : new Error('' + value) | |
| } | |
| export function setOwnerStackIfAvailable(error: Error): void { | |
| // React 18 and prod does not have `captureOwnerStack` | |
| if ('captureOwnerStack' in React) { | |
| const ownerStack = React.captureOwnerStack() | |
| // Only set if we captured a valid owner stack, or if none exists yet. | |
| // This prevents overwriting a valid owner stack captured earlier | |
| // (e.g., in onRecoverableError) with null captured later. | |
| if (ownerStack || !ownerStacks.has(error)) { | |
| setOwnerStack(error, ownerStack) | |
| } | |
| } | |
| } | |
| export function decorateDevError(thrownValue: unknown) { | |
| const error = coerceError(thrownValue) | |
| setOwnerStackIfAvailable(error) | |
| return error | |
| } | |
Xet Storage Details
- Size:
- 1.12 kB
- Xet hash:
- 11bfcf10a051077e8f5f177447725baad40288503eccc3447fcd2304eb602ce7
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.