-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
421 additions
and
1,955 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
const Logger = use('Logger'); | ||
const JsonApi = use('JsonApi'); | ||
|
||
/** | ||
* This class handles all exceptions thrown during | ||
* the HTTP request lifecycle. | ||
* | ||
* @class ExceptionHandler | ||
*/ | ||
class ExceptionHandler { | ||
/** | ||
* Handle exception thrown during the HTTP lifecycle | ||
* | ||
* @method handle | ||
* | ||
* @param {Object} error | ||
* @param {Object} options.request | ||
* @param {Object} options.response | ||
* | ||
* @return {void} | ||
*/ | ||
async handle(error, options) { | ||
JsonApi.handleError(error, options); | ||
} | ||
|
||
/** | ||
* Report exception for logging or debugging. | ||
* | ||
* @method report | ||
* | ||
* @param {Object} error | ||
* @param {Object} options.request | ||
* | ||
* @return {void} | ||
*/ | ||
async report(error, {request}) { | ||
Logger.error(error); | ||
} | ||
} | ||
|
||
module.exports = ExceptionHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.