aboutsummaryrefslogtreecommitdiffstats
path: root/src/internal-server/app/Exceptions/Handler.js
diff options
context:
space:
mode:
authorLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-08-01 11:07:57 +0000
committerLibravatar GitHub <noreply@github.com>2021-08-01 16:37:57 +0530
commit419933f6505caf4c5e685f8436b1ff735185e55a (patch)
tree152dcb9d2b35d29f862cc57a605b9ae2a0f7c300 /src/internal-server/app/Exceptions/Handler.js
parentRemoved duplicated contributors badge. (diff)
downloadferdium-app-419933f6505caf4c5e685f8436b1ff735185e55a.tar.gz
ferdium-app-419933f6505caf4c5e685f8436b1ff735185e55a.tar.zst
ferdium-app-419933f6505caf4c5e685f8436b1ff735185e55a.zip
Moved 'internal-server' into a sub-folder as opposed to a git submodule. (#1715)
* Ignored tests in 'internal-server' folder since there are none. * Linter fixes
Diffstat (limited to 'src/internal-server/app/Exceptions/Handler.js')
-rw-r--r--src/internal-server/app/Exceptions/Handler.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/internal-server/app/Exceptions/Handler.js b/src/internal-server/app/Exceptions/Handler.js
new file mode 100644
index 000000000..111ef4e0e
--- /dev/null
+++ b/src/internal-server/app/Exceptions/Handler.js
@@ -0,0 +1,44 @@
1const BaseExceptionHandler = use('BaseExceptionHandler');
2
3/**
4 * This class handles all exceptions thrown during
5 * the HTTP request lifecycle.
6 *
7 * @class ExceptionHandler
8 */
9class ExceptionHandler extends BaseExceptionHandler {
10 /**
11 * Handle exception thrown during the HTTP lifecycle
12 *
13 * @method handle
14 *
15 * @param {Object} error
16 * @param {Object} options.request
17 * @param {Object} options.response
18 *
19 * @return {void}
20 */
21 async handle(error, { response }) {
22 if (error.name === 'ValidationException') {
23 return response.status(400).send('Invalid arguments');
24 }
25
26 return response.status(error.status).send(error.message);
27 }
28
29 /**
30 * Report exception for logging or debugging.
31 *
32 * @method report
33 *
34 * @param {Object} error
35 * @param {Object} options.request
36 *
37 * @return {void}
38 */
39 async report() {
40 return true;
41 }
42}
43
44module.exports = ExceptionHandler;