MCPcopy
hub / github.com/facebook/react / serializeDebugErrorValue

Function serializeDebugErrorValue

packages/react-server/src/ReactFlightServer.js:4099–4133  ·  view source on GitHub ↗
(request: Request, error: Error)

Source from the content-addressed store, hash-verified

4097}
4098
4099function serializeDebugErrorValue(request: Request, error: Error): string {
4100 if (__DEV__) {
4101 let name: string = 'Error';
4102 let message: string;
4103 let stack: ReactStackTrace;
4104 let env = (0, request.environmentName)();
4105 try {
4106 name = error.name;
4107 // eslint-disable-next-line react-internal/safe-string-coercion
4108 message = String(error.message);
4109 stack = filterStackTrace(request, parseStackTrace(error, 0));
4110 const errorEnv = (error: any).environmentName;
4111 if (typeof errorEnv === 'string') {
4112 // This probably came from another FlightClient as a pass through.
4113 // Keep the environment name.
4114 env = errorEnv;
4115 }
4116 } catch (x) {
4117 message = 'An error occurred but serializing the error message failed.';
4118 stack = [];
4119 }
4120 const errorInfo: ReactErrorInfoDev = {name, message, stack, env};
4121 const id = outlineDebugModel(
4122 request,
4123 {objectLimit: stack.length * 2 + 1},
4124 errorInfo,
4125 );
4126 return '$Z' + id.toString(16);
4127 } else {
4128 // In prod we don't emit any information about this Error object to avoid
4129 // unintentional leaks. Since this doesn't actually throw on the server
4130 // we don't go through onError and so don't register any digest neither.
4131 return '$Z';
4132 }
4133}
4134
4135function emitErrorChunk(
4136 request: Request,

Callers 1

renderDebugModelFunction · 0.85

Calls 4

filterStackTraceFunction · 0.85
outlineDebugModelFunction · 0.85
parseStackTraceFunction · 0.70
toStringMethod · 0.65

Tested by

no test coverage detected