Skip to content

Commit

Permalink
feat: show os notifications for errors; fixes #247
Browse files Browse the repository at this point in the history
  • Loading branch information
davewasmer committed Sep 3, 2017
1 parent 7749eb5 commit d72d8da
Show file tree
Hide file tree
Showing 4 changed files with 861 additions and 1,139 deletions.
12 changes: 12 additions & 0 deletions app/actions/error.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import * as assert from 'assert';
import * as path from 'path';
import * as notifier from 'node-notifier';
import Action from '../../lib/runtime/action';
import Logger from '../../lib/runtime/logger';
import FlatParser from '../../lib/parse/flat';
import inject from '../../lib/metal/inject';
import Application from '../../lib/runtime/application';

/**
* The default error action. When Denali encounters an error while processing a request, it will
Expand All @@ -22,6 +25,7 @@ export default class ErrorAction extends Action {

logger = inject<Logger>('app:logger');
parser = inject<FlatParser>('parser:flat');
application = inject<Application>('app:main');

/**
* Respond with JSON by default
Expand Down Expand Up @@ -49,6 +53,14 @@ export default class ErrorAction extends Action {
}
delete error.stack;
}
if (!this.config.logging.hideOSNotifications) {
notifier.notify({
title: `Request failed: ${ this.application.pkg.name } Error`,
message: error.message,
icon: path.join(__dirname, '../views/error-notification-icon.png'),
sound: true
});
}
if (this.request.accepts([ 'html' ]) && this.container.lookup('config:environment').environment !== 'production') {
this.render(error.status, error, { view: 'error.html' });
} else {
Expand Down
Binary file added app/views/error-notification-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@types/mkdirp": "^0.5.1",
"@types/morgan": "^1.7.32",
"@types/node": "^8.0.26",
"@types/node-notifier": "^0.0.28",
"@types/response-time": "^2.3.1",
"@types/rimraf": "^2.0.2",
"@types/route-parser": "^0.1.1",
Expand Down Expand Up @@ -104,6 +105,7 @@
"mkdirp": "^0.5.1",
"moment": "^2.18.1",
"morgan": "^1.8.2",
"node-notifier": "^5.1.2",
"read-pkg": "^2.0.0",
"response-time": "^2.3.1",
"route-parser": "0.0.5",
Expand Down
Loading

0 comments on commit d72d8da

Please sign in to comment.