(error: any)
| 1165 | } |
| 1166 | |
| 1167 | function handleRenderFunctionError(error: any): void { |
| 1168 | // original error might be any type. |
| 1169 | if (error === SuspenseException) { |
| 1170 | // An uncached Promise was used. We can't synchronously resolve the rest of |
| 1171 | // the Hooks but we can at least show what ever we got so far. |
| 1172 | return; |
| 1173 | } |
| 1174 | if ( |
| 1175 | error instanceof Error && |
| 1176 | error.name === 'ReactDebugToolsUnsupportedHookError' |
| 1177 | ) { |
| 1178 | throw error; |
| 1179 | } |
| 1180 | // If the error is not caused by an unsupported feature, it means |
| 1181 | // that the error is caused by user's code in renderFunction. |
| 1182 | // In this case, we should wrap the original error inside a custom error |
| 1183 | // so that devtools can give a clear message about it. |
| 1184 | // $FlowFixMe[extra-arg]: Flow doesn't know about 2nd argument of Error constructor |
| 1185 | const wrapperError = new Error('Error rendering inspected component', { |
| 1186 | cause: error, |
| 1187 | }); |
| 1188 | // Note: This error name needs to stay in sync with react-devtools-shared |
| 1189 | // TODO: refactor this if we ever combine the devtools and debug tools packages |
| 1190 | wrapperError.name = 'ReactDebugToolsRenderError'; |
| 1191 | // this stage-4 proposal is not supported by all environments yet. |
| 1192 | // $FlowFixMe[prop-missing] Flow doesn't have this type yet. |
| 1193 | wrapperError.cause = error; |
| 1194 | throw wrapperError; |
| 1195 | } |
| 1196 | |
| 1197 | export function inspectHooks<Props>( |
| 1198 | renderFunction: Props => React$Node, |
no outgoing calls
no test coverage detected