From 879587d62b8606ab3d57e4a7b0c484f75b64cbda Mon Sep 17 00:00:00 2001 From: xnacly Date: Fri, 3 Sep 2021 21:29:17 +0200 Subject: moved Constants and Errorhandler from api to util --- api/src/util/ApiError.ts | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 api/src/util/ApiError.ts (limited to 'api/src/util/ApiError.ts') diff --git a/api/src/util/ApiError.ts b/api/src/util/ApiError.ts deleted file mode 100644 index c133e6e7..00000000 --- a/api/src/util/ApiError.ts +++ /dev/null @@ -1,27 +0,0 @@ -export class ApiError extends Error { - constructor( - readonly message: string, - public readonly code: number, - public readonly httpStatus: number = 400, - public readonly defaultParams?: string[] - ) { - super(message); - } - - withDefaultParams(): ApiError { - if (this.defaultParams) return new ApiError(applyParamsToString(this.message, this.defaultParams), this.code, this.httpStatus); - return this; - } - - withParams(...params: (string | number)[]): ApiError { - return new ApiError(applyParamsToString(this.message, params), this.code, this.httpStatus); - } -} - -export function applyParamsToString(s: string, params: (string | number)[]): string { - let newString = s; - params.forEach((a) => { - newString = newString.replace("{}", "" + a); - }); - return newString; -} -- cgit 1.5.1