Skip to content

Commit

Permalink
Register the warning capture
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed May 11, 2017
1 parent 47cd783 commit cf897f0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/react-error-overlay/src/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import {
register as registerStackTraceLimit,
unregister as unregisterStackTraceLimit,
} from './effects/stackTraceLimit';
import {
permanentRegister as permanentRegisterConsole,
} from './effects/proxyConsole';

import {
consume as consumeError,
Expand Down Expand Up @@ -205,6 +208,26 @@ function inject() {
registerPromise(window, error => crash(error, true));
registerShortcuts(window, shortcutHandler);
registerStackTraceLimit();

permanentRegisterConsole('error', warning => {
const nIndex = warning.indexOf('\n');
let message = warning;
if (nIndex !== -1) {
message = message.substring(0, nIndex);
}
const stack = warning.substring(nIndex + 1);
window.requestAnimationFrame(function() {
return crash(
// $FlowFixMe
{
message: message,
stack: stack,
__unmap_source: '/static/js/bundle.js',
},
false
);
});
});
}

function uninject() {
Expand Down

0 comments on commit cf897f0

Please sign in to comment.