[client-app] Fix unhandled rejection handling (fix ipc parse error)

Summary:
Previously, we were listening for unhanlded rejections on both the
`window` and the `process`. However, the window handler didn't receive
an error as a parameter, but rather a window event. When trying to
report this event and sending it over IPC we would get an ipc parse
error.

This commit makes it so we correctly report the error instead of the
window event.

Test Plan: manual

Reviewers: mark, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4412
This commit is contained in:
Juan Tejada 2017-04-12 10:21:07 -07:00
parent d30559aa6e
commit b6771ea745

View file

@ -277,7 +277,6 @@ export default class NylasEnvConstructor {
originalError.stack = convertStackTrace(originalError.stack, sourceMapCache);
return this.reportError(originalError, {url, line: newLine, column: newColumn});
};
window.addEventListener("unhandledrejection", e => this.reportError(e));
process.on('uncaughtException', e => this.reportError(e));
@ -293,7 +292,15 @@ export default class NylasEnvConstructor {
if (this.inDevMode()) {
error.stack = convertStackTrace(error.stack, sourceMapCache);
}
return this.reportError(error);
this.reportError(error);
});
window.addEventListener('unhandledrejection', e => {
const error = e.detail.reason
if (this.inDevMode()) {
error.stack = convertStackTrace(error.stack, sourceMapCache);
}
this.reportError(error)
});
if (this.inSpecMode() || (this.inDevMode() && !this.inBenchmarkMode())) {