diff --git a/package.json b/package.json index b17fd94..069e0e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wms-core", - "version": "0.10.22", + "version": "0.10.23", "description": "Node web framework", "repository": "git@gitlab.com:ArisuOngaku/wms-core.git", "author": "Alice Gaudon ", diff --git a/src/HttpError.ts b/src/HttpError.ts index 3e7b314..e76ace4 100644 --- a/src/HttpError.ts +++ b/src/HttpError.ts @@ -3,7 +3,7 @@ import {WrappingError} from "./Utils"; export abstract class HttpError extends WrappingError { public readonly instructions: string; - constructor(message: string, instructions: string, cause?: Error) { + protected constructor(message: string, instructions: string, cause?: Error) { super(message, cause); 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 { constructor(thing: string, url: string, cause?: Error) { super(