aboutsummaryrefslogtreecommitdiffstats
path: root/app/Exceptions/Handler.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/Exceptions/Handler.js')
-rw-r--r--app/Exceptions/Handler.js48
1 files changed, 0 insertions, 48 deletions
diff --git a/app/Exceptions/Handler.js b/app/Exceptions/Handler.js
deleted file mode 100644
index 43c3ef1..0000000
--- a/app/Exceptions/Handler.js
+++ /dev/null
@@ -1,48 +0,0 @@
1const BaseExceptionHandler = use('BaseExceptionHandler');
2const Sentry = require('@sentry/node');
3
4/**
5 * This class handles all exceptions thrown during
6 * the HTTP request lifecycle.
7 *
8 * @class ExceptionHandler
9 */
10class ExceptionHandler extends BaseExceptionHandler {
11 /**
12 * Handle exception thrown during the HTTP lifecycle
13 *
14 * @method handle
15 *
16 * @param {Object} error
17 * @param {Object} options.request
18 * @param {Object} options.response
19 *
20 * @return {void}
21 */
22 async handle(error, { response }) {
23 if (error.name === 'ValidationException') {
24 return response.status(400).send('Invalid arguments');
25 } if (error.name === 'InvalidSessionException') {
26 return response.status(401).redirect('/user/login');
27 }
28
29 return response.status(error.status).send(error.message);
30 }
31
32 /**
33 * Report exception for logging or debugging.
34 *
35 * @method report
36 *
37 * @param {Object} error
38 * @param {Object} options.request
39 *
40 * @return {void}
41 */
42 async report(error) {
43 Sentry.captureException(error);
44 return true;
45 }
46}
47
48module.exports = ExceptionHandler;