Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cb-#99] simplifying request-resource-response lifecycle
- Loading branch information
Showing
9 changed files
with
168 additions
and
274 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,38 @@ | ||
/** | ||
* @memberof Drash.Exceptions | ||
* @class HttpResponseException | ||
* | ||
* @description | ||
* This class gives you a way to throw HTTP errors semantically in the | ||
* response class. The difference between this class and `HttpException` | ||
* comes when you want to check which exception was thrown via | ||
* `exception.constructor.name`. | ||
* | ||
* This class extends `Error`. | ||
*/ | ||
export default class HttpResponseException extends Error { | ||
/** | ||
* @description | ||
* A property to hold the HTTP response code associated with this | ||
* exception. | ||
* | ||
* @property number code | ||
*/ | ||
public code: number; | ||
|
||
// FILE MARKER: CONSTRUCTOR ////////////////////////////////////////////////// | ||
|
||
/** | ||
* @description | ||
* Construct an object of this class. | ||
* | ||
* @param number code | ||
* The HTTP response code associated with this exception. | ||
* @param string message | ||
* (optional) The exception message. | ||
*/ | ||
constructor(code: number, message?: string) { | ||
super(message); | ||
this.code = code; | ||
} | ||
} |
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
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
Oops, something went wrong.