( request: Request, error: mixed, task: Task | null, // DEV-only )
| 3973 | } |
| 3974 | |
| 3975 | function logRecoverableError( |
| 3976 | request: Request, |
| 3977 | error: mixed, |
| 3978 | task: Task | null, // DEV-only |
| 3979 | ): string { |
| 3980 | const prevRequest = currentRequest; |
| 3981 | // We clear the request context so that console.logs inside the callback doesn't |
| 3982 | // get forwarded to the client. |
| 3983 | currentRequest = null; |
| 3984 | let errorDigest; |
| 3985 | try { |
| 3986 | const onError = request.onError; |
| 3987 | if (__DEV__ && task !== null) { |
| 3988 | if (supportsRequestStorage) { |
| 3989 | errorDigest = requestStorage.run( |
| 3990 | undefined, |
| 3991 | callWithDebugContextInDEV, |
| 3992 | request, |
| 3993 | task, |
| 3994 | onError, |
| 3995 | error, |
| 3996 | ); |
| 3997 | } else { |
| 3998 | errorDigest = callWithDebugContextInDEV(request, task, onError, error); |
| 3999 | } |
| 4000 | } else if (supportsRequestStorage) { |
| 4001 | // Exit the request context while running callbacks. |
| 4002 | errorDigest = requestStorage.run(undefined, onError, error); |
| 4003 | } else { |
| 4004 | errorDigest = onError(error); |
| 4005 | } |
| 4006 | } finally { |
| 4007 | currentRequest = prevRequest; |
| 4008 | } |
| 4009 | if (errorDigest != null && typeof errorDigest !== 'string') { |
| 4010 | // eslint-disable-next-line react-internal/prod-error-codes |
| 4011 | throw new Error( |
| 4012 | `onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "${typeof errorDigest}" instead`, |
| 4013 | ); |
| 4014 | } |
| 4015 | return errorDigest || ''; |
| 4016 | } |
| 4017 | |
| 4018 | function fatalError(request: Request, error: mixed): void { |
| 4019 | const onFatalError = request.onFatalError; |
no test coverage detected