From 641466a7315fe6869e9b41cdb855cc52cf5487f9 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Tue, 29 Dec 2020 20:00:31 +0100 Subject: [PATCH] Added basic errors for stats clients ref #56 --- src/errors/StatsClientErrors.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/errors/StatsClientErrors.ts diff --git a/src/errors/StatsClientErrors.ts b/src/errors/StatsClientErrors.ts new file mode 100644 index 0000000..ab7f1ef --- /dev/null +++ b/src/errors/StatsClientErrors.ts @@ -0,0 +1,25 @@ +import { IsString } from 'class-validator'; +import { NotAcceptableError, NotFoundError } from 'routing-controllers'; + +/** + * Error to throw, when a non-existant stats client get's loaded. + */ +export class StatsClientNotFoundError extends NotFoundError { + @IsString() + name = "StatsClientNotFoundError" + + @IsString() + message = "The stats client you provided couldn't be located in the system. \n Please check your request." +} + +/** + * Error to throw when two stats clients' ids don't match. + * Usually occurs when a user tries to change a stats client's id. + */ +export class StatsClientIdsNotMatchingError extends NotAcceptableError { + @IsString() + name = "StatsClientIdsNotMatchingError" + + @IsString() + message = "The ids don't match! \n And if you wanted to change a stats client's id: This isn't allowed!" +} \ No newline at end of file