1287
createFormData,
1288
);
1289
}
1290
+ case 'Z': {
1291
+ // Error
1292
+ if (__DEV__) {
1293
+ const ref = value.slice(2);
1294
+ return getOutlinedModel(
1295
+ response,
1296
+ ref,
1297
+ parentObject,
1298
+ key,
1299
+ resolveErrorDev,
1300
+ );
1301
+ } else {
1302
+ return resolveErrorProd(response);
1303
+ }
1304
+ }
1305
case 'i': {
1306
// Iterator
1307
const ref = value.slice(2);
1896
}
1897
1898
type ErrorWithDigest = Error & {digest?: string};
1884
-function resolveErrorProd(
1885
- response: Response,
1886
- id: number,
1887
- digest: string,
1888
-): void {
1899
+function resolveErrorProd(response: Response): Error {
1900
if (__DEV__) {
1901
// These errors should never make it into a build so we don't need to encode them in codes.json
1902
// eslint-disable-next-line react-internal/prod-error-codes
1910
' may provide additional details about the nature of the error.',
1911
);
1912
error.stack = 'Error: ' + error.message;
1902
- (error: any).digest = digest;
1903
- const errorWithDigest: ErrorWithDigest = (error: any);
1904
- const chunks = response._chunks;
1905
- const chunk = chunks.get(id);
1906
- if (!chunk) {
1907
- chunks.set(id, createErrorChunk(response, errorWithDigest));
1908
- } else {
1909
- triggerErrorOnChunk(chunk, errorWithDigest);
1910
- }
1913
+ return error;
1914
}
1915
1916
function resolveErrorDev(
1917
response: Response,
1915
- id: number,
1916
- digest: string,
1917
- message: string,
1918
- stack: ReactStackTrace,
1919
- env: string,
1920
-): void {
1918
+ errorInfo: {message: string, stack: ReactStackTrace, env: string, ...},
1919
+): Error {
1920
+ const message: string = errorInfo.message;
1921
+ const stack: ReactStackTrace = errorInfo.stack;
1922
+ const env: string = errorInfo.env;
1923
+
1924
if (!__DEV__) {
1925
// These errors should never make it into a build so we don't need to encode them in codes.json
1926
// eslint-disable-next-line react-internal/prod-error-codes
1960
}
1961
}
1962
1960
- (error: any).digest = digest;
1963
(error: any).environmentName = env;
1962
- const errorWithDigest: ErrorWithDigest = (error: any);
1963
- const chunks = response._chunks;
1964
- const chunk = chunks.get(id);
1965
- if (!chunk) {
1966
- chunks.set(id, createErrorChunk(response, errorWithDigest));
1967
- } else {
1968
- triggerErrorOnChunk(chunk, errorWithDigest);
1969
- }
1964
+ return error;
1965
}
1966
1967
function resolvePostponeProd(response: Response, id: number): void {
2617
}
2618
case 69 /* "E" */: {
2619
const errorInfo = JSON.parse(row);
2620
+ let error;
2621
if (__DEV__) {
2626
- resolveErrorDev(
2627
- response,
2628
- id,
2629
- errorInfo.digest,
2630
- errorInfo.message,
2631
- errorInfo.stack,
2632
- errorInfo.env,
2633
- );
2622
+ error = resolveErrorDev(response, errorInfo);
2623
+ } else {
2624
+ error = resolveErrorProd(response);
2625
+ }
2626
+ (error: any).digest = errorInfo.digest;
2627
+ const errorWithDigest: ErrorWithDigest = (error: any);
2628
+ const chunks = response._chunks;
2629
+ const chunk = chunks.get(id);
2630
+ if (!chunk) {
2631
+ chunks.set(id, createErrorChunk(response, errorWithDigest));
2632
} else {
2635
- resolveErrorProd(response, id, errorInfo.digest);
2633
+ triggerErrorOnChunk(chunk, errorWithDigest);
2634
}
2635
return;
2636
}