|
1 | 1 | import { stringify } from 'circular-json'; |
2 | 2 | import configureStore from '../../../app/store/configureStore'; |
3 | 3 | import { isAllowed } from '../options/syncOptions'; |
| 4 | +import notifyErrors from '../utils/notifyErrors'; |
4 | 5 |
|
5 | 6 | window.devToolsExtension = function(next) { |
6 | 7 | let store = {}; |
@@ -97,7 +98,15 @@ window.devToolsExtension = function(next) { |
97 | 98 |
|
98 | 99 | function init() { |
99 | 100 | window.addEventListener('message', onMessage, false); |
100 | | - window.devToolsExtension.notifyErrors(store, relay, () => { errorOccurred = true; }); |
| 101 | + notifyErrors(() => { |
| 102 | + errorOccurred = true; |
| 103 | + const state = store.liftedStore.getState(); |
| 104 | + if (state.computedStates[state.currentStateIndex].error) { |
| 105 | + relay('STATE', state); |
| 106 | + return false; |
| 107 | + } |
| 108 | + return true; |
| 109 | + }); |
101 | 110 | } |
102 | 111 |
|
103 | 112 | if (next) { |
@@ -127,26 +136,4 @@ window.devToolsExtension.open = function(position) { |
127 | 136 | }, '*'); |
128 | 137 | }; |
129 | 138 |
|
130 | | -// Catch errors |
131 | | -window.devToolsExtension.notifyErrors = function(store, relay, onError) { |
132 | | - function postError(message) { |
133 | | - if (store && store.liftedStore && relay) { |
134 | | - const state = store.liftedStore.getState(); |
135 | | - if (state.computedStates[state.currentStateIndex].error) { |
136 | | - relay('STATE', state); |
137 | | - if (onError) onError(); |
138 | | - return; |
139 | | - } |
140 | | - } |
141 | | - window.postMessage({ |
142 | | - source: 'redux-page', |
143 | | - type: 'ERROR', |
144 | | - message: message |
145 | | - }, '*'); |
146 | | - } |
147 | | - function catchErrors(e) { |
148 | | - if (window.devToolsOptions && !window.devToolsOptions.notifyErrors) return; |
149 | | - postError(e.message); |
150 | | - } |
151 | | - window.addEventListener('error', catchErrors, false); |
152 | | -}; |
| 139 | +window.devToolsExtension.notifyErrors = notifyErrors; |
0 commit comments