mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-15 22:29:03 +08:00
918090a4e1
Summary:
The goal is to let us see what plugins are throwing errors on Sentry.
We are using a Sentry `tag` to identify and group plugins and their
errors.
Along the way, I cleaned up the error catching and reporting system. There
was a lot of duplicate error logic (that wasn't always right) and some
legacy Atom error handling.
Now, if you catch an error that we should report (like when handling
extensions), call `NylasEnv.reportError`. This used to be called
`emitError` but I changed it to `reportError` to be consistent with the
ErrorReporter and be a bit more indicative of what it does.
In the production version, the `ErrorLogger` will forward the request to
the `nylas-private-error-reporter` which will report to Sentry.
The `reportError` function also now inspects the stack to determine which
plugin(s) it came from. These are passed along to Sentry.
I also cleaned up the `console.log` and `console.error` code. We were
logging errors multiple times making the console confusing to read. Worse
is that we were logging the `error` object, which would print not the
stack of the actual error, but rather the stack of where the console.error
was logged from. Printing `error.stack` instead shows much more accurate
stack traces.
See changes in the Edgehill repo here: 8c4a86eb7e
Test Plan: Manual
Reviewers: juan, bengotow
Reviewed By: bengotow
Differential Revision: https://phab.nylas.com/D2509
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
// argv[0] = node
|
|
// argv[1] = jasmine
|
|
// argv[2] = JASMINE_CONFIG_PATH=./jasmine/config.json
|
|
// argv[3] = NYLAS_ROOT_PATH=/path/to/nylas/root
|
|
var babelOptions = require('../../static/babelrc.json');
|
|
require('babel-core/register')(babelOptions);
|
|
|
|
var chalk = require('chalk')
|
|
var util = require('util')
|
|
|
|
console.errorColor = function(err){
|
|
if (typeof err === "string") {
|
|
console.error(chalk.red(err));
|
|
} else {
|
|
console.error(chalk.red(util.inspect(err)));
|
|
}
|
|
}
|
|
|
|
console.inspect = function(val) {
|
|
console.log(util.inspect(val, true, depth=7, colorize=true));
|
|
}
|
|
|
|
jasmine.NYLAS_ROOT_PATH = process.argv[3].split("NYLAS_ROOT_PATH=")[1]
|
|
jasmine.UNIT_TEST_TIMEOUT = 120*1000;
|
|
jasmine.BOOT_TIMEOUT = 30*1000;
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30*1000
|
|
|
|
Promise = require('bluebird')
|
|
Promise.config({
|
|
warnings: true,
|
|
longStackTraces: true,
|
|
cancellation: true
|
|
})
|
|
|
|
process.on("unhandledRejection", function(reason, promise) {
|
|
if (reason.stack) { console.errorColor(reason.stack); }
|
|
console.errorColor(promise);
|
|
});
|
|
|
|
process.on("uncaughtException", function(error) {
|
|
if (error.stack) { console.errorColor(error.stack); }
|
|
console.errorColor(error);
|
|
});
|