Add 401 unauthorized http error
This commit is contained in:
parent
724d59daba
commit
5b80c3ac07
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wms-core",
|
"name": "wms-core",
|
||||||
"version": "0.10.22",
|
"version": "0.10.23",
|
||||||
"description": "Node web framework",
|
"description": "Node web framework",
|
||||||
"repository": "git@gitlab.com:ArisuOngaku/wms-core.git",
|
"repository": "git@gitlab.com:ArisuOngaku/wms-core.git",
|
||||||
"author": "Alice Gaudon <alice@gaudon.pro>",
|
"author": "Alice Gaudon <alice@gaudon.pro>",
|
||||||
|
@ -3,7 +3,7 @@ import {WrappingError} from "./Utils";
|
|||||||
export abstract class HttpError extends WrappingError {
|
export abstract class HttpError extends WrappingError {
|
||||||
public readonly instructions: string;
|
public readonly instructions: string;
|
||||||
|
|
||||||
constructor(message: string, instructions: string, cause?: Error) {
|
protected constructor(message: string, instructions: string, cause?: Error) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
this.instructions = instructions;
|
this.instructions = instructions;
|
||||||
}
|
}
|
||||||
@ -28,6 +28,16 @@ export class BadRequestError extends HttpError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class UnauthorizedHttpError extends BadRequestError {
|
||||||
|
constructor(message: string, url: string, cause?: Error) {
|
||||||
|
super(message, '', url, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
get errorCode(): number {
|
||||||
|
return 401;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class ForbiddenHttpError extends BadRequestError {
|
export class ForbiddenHttpError extends BadRequestError {
|
||||||
constructor(thing: string, url: string, cause?: Error) {
|
constructor(thing: string, url: string, cause?: Error) {
|
||||||
super(
|
super(
|
||||||
|
Loading…
Reference in New Issue
Block a user