1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export function _catchError(error, vnode, oldVNode, errorInfo) {
|
11 |
|
12 | let component, ctor, handled;
|
13 |
|
14 | for (; (vnode = vnode._parent); ) {
|
15 | if ((component = vnode._component) && !component._processingException) {
|
16 | try {
|
17 | ctor = component.constructor;
|
18 |
|
19 | if (ctor && ctor.getDerivedStateFromError != null) {
|
20 | component.setState(ctor.getDerivedStateFromError(error));
|
21 | handled = component._dirty;
|
22 | }
|
23 |
|
24 | if (component.componentDidCatch != null) {
|
25 | component.componentDidCatch(error, errorInfo || {});
|
26 | handled = component._dirty;
|
27 | }
|
28 |
|
29 |
|
30 | if (handled) {
|
31 | return (component._pendingError = component);
|
32 | }
|
33 | } catch (e) {
|
34 | error = e;
|
35 | }
|
36 | }
|
37 | }
|
38 |
|
39 | throw error;
|
40 | }
|