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

Function reject

packages/react-client/src/ReactFlightClient.js:1867–1911  ·  packages/react-client/src/ReactFlightClient.js::reject
(error: mixed)

Source from the content-addressed store, hash-verified

1865 }
1866
1867 function reject(error: mixed): void {
1868 if (handler.errored) {
1869 class="cm">// We've already errored. We could instead build up an AggregateError
1870 class="cm">// but if there are multiple errors we just take the first one like
1871 class="cm">// Promise.all.
1872 return;
1873 }
1874 const blockedValue = handler.value;
1875 handler.errored = true;
1876 handler.value = null;
1877 handler.reason = error;
1878 const chunk = handler.chunk;
1879 if (chunk === null || chunk.status !== BLOCKED) {
1880 return;
1881 }
1882
1883 if (__DEV__) {
1884 if (
1885 typeof blockedValue === class="st">'object' &&
1886 blockedValue !== null &&
1887 blockedValue.$$typeof === REACT_ELEMENT_TYPE
1888 ) {
1889 const element = blockedValue;
1890 class="cm">// Conceptually the error happened inside this Element but right before
1891 class="cm">// it was rendered. We don't have a client side component to render but
1892 class="cm">// we can add some DebugInfo to explain that this was conceptually a
1893 class="cm">// Server side error that errored inside this element. That way any stack
1894 class="cm">// traces will point to the nearest JSX that errored - e.g. during
1895 class="cm">// serialization.
1896 const erroredComponent: ReactComponentInfo = {
1897 name: getComponentNameFromType(element.type) || class="st">'',
1898 owner: element._owner,
1899 };
1900 class="cm">// $FlowFixMe[cannot-write]
1901 erroredComponent.debugStack = element._debugStack;
1902 if (supportsCreateTask) {
1903 class="cm">// $FlowFixMe[cannot-write]
1904 erroredComponent.debugTask = element._debugTask;
1905 }
1906 chunk._debugInfo.push(erroredComponent);
1907 }
1908 }
1909
1910 triggerErrorOnChunk(response, chunk, error);
1911 }
1912
1913 promise.then(fulfill, reject);
1914

Callers 15

progressFunction · 0.70
retryFunction · 0.70
resolveToJSONFunction · 0.70
encodeFormDataFunction · 0.70
abortMethod · 0.50
thenFunction · 0.50
makeDelayedTextFunction · 0.50
arrayBufferFunction · 0.50

Calls 2

getComponentNameFromTypeFunction · 0.85
pushMethod · 0.65

Tested by 7

abortMethod · 0.40
makeDelayedTextFunction · 0.40
arrayBufferFunction · 0.40
readResultFunction · 0.40
getDataFunction · 0.40
thenFunction · 0.40
readResultFunction · 0.40