Skip to content

Commit cf897f0

Browse files
committed
Register the warning capture
1 parent 47cd783 commit cf897f0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/react-error-overlay/src/overlay.js

+23
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import {
1919
register as registerStackTraceLimit,
2020
unregister as unregisterStackTraceLimit,
2121
} from './effects/stackTraceLimit';
22+
import {
23+
permanentRegister as permanentRegisterConsole,
24+
} from './effects/proxyConsole';
2225

2326
import {
2427
consume as consumeError,
@@ -205,6 +208,26 @@ function inject() {
205208
registerPromise(window, error => crash(error, true));
206209
registerShortcuts(window, shortcutHandler);
207210
registerStackTraceLimit();
211+
212+
permanentRegisterConsole('error', warning => {
213+
const nIndex = warning.indexOf('\n');
214+
let message = warning;
215+
if (nIndex !== -1) {
216+
message = message.substring(0, nIndex);
217+
}
218+
const stack = warning.substring(nIndex + 1);
219+
window.requestAnimationFrame(function() {
220+
return crash(
221+
// $FlowFixMe
222+
{
223+
message: message,
224+
stack: stack,
225+
__unmap_source: '/static/js/bundle.js',
226+
},
227+
false
228+
);
229+
});
230+
});
208231
}
209232

210233
function uninject() {

0 commit comments

Comments
 (0)