Fixed handling non-Ghost errors in Sentry

no issue

- in the near future, non-Ghost Ignition type errors will be coming into
  Sentry
- because they don't have a statusCode, they'll be rejected
- we want to detect if they're non-Ghost and still deal with them
This commit is contained in:
Daniel Lockyer 2020-06-01 19:01:51 +01:00
parent 3701d6e919
commit 310ecd37c4

View File

@ -1,5 +1,6 @@
const config = require('./config');
const sentryConfig = config.get('sentry');
const errors = require('@tryghost/errors');
const expressNoop = function (req, res, next) {
next();
@ -19,6 +20,12 @@ if (sentryConfig && !sentryConfig.disabled) {
requestHandler: Sentry.Handlers.requestHandler(),
errorHandler: Sentry.Handlers.errorHandler({
shouldHandleError(error) {
// Sometimes non-Ghost issues will come into here but they won't
// have a statusCode so we should always handle them
if (!errors.utils.isIgnitionError(error)) {
return true;
}
// Only handle 500 errors for now
// This is because the only other 5XX error should be 503, which are deliberate maintenance/boot errors
return (error.statusCode === 500);