summary refs log tree commit diff
path: root/api/src/util/ApiError.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-04 11:26:47 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-04 11:26:47 +0200
commit2e9f36b66ad99140fe1312a8b2bdfaf7b0e9d6bb (patch)
treefcd3733bf36327c988c95892d548d4e5d628f505 /api/src/util/ApiError.ts
parent:bug: api member add roles -> make sure that roles exist (diff)
parentfixed /discoverable-guilds (diff)
downloadserver-2e9f36b66ad99140fe1312a8b2bdfaf7b0e9d6bb.tar.xz
Merge branch 'master' of https://github.com/fosscord/fosscord-api
Diffstat (limited to 'api/src/util/ApiError.ts')
-rw-r--r--api/src/util/ApiError.ts27
1 files changed, 0 insertions, 27 deletions
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; -}