From 246660d53a4f06cdfb555893401440140cd526de Mon Sep 17 00:00:00 2001 From: pxseu <57842793+pxseu@users.noreply.github.com> Date: Sun, 10 Oct 2021 16:49:50 +0200 Subject: [PATCH] feat(errors): move errors and create new classes --- .../{HTTPErrors => Imperial}/DocumentNotFound.ts | 0 .../NotAllowed.ts => Imperial/EditNotAllowed.ts} | 0 src/lib/errors/Imperial/WrongPassword.ts | 10 ++++++++++ src/lib/errors/index.ts | 5 +++-- 4 files changed, 13 insertions(+), 2 deletions(-) rename src/lib/errors/{HTTPErrors => Imperial}/DocumentNotFound.ts (100%) rename src/lib/errors/{HTTPErrors/NotAllowed.ts => Imperial/EditNotAllowed.ts} (100%) create mode 100644 src/lib/errors/Imperial/WrongPassword.ts diff --git a/src/lib/errors/HTTPErrors/DocumentNotFound.ts b/src/lib/errors/Imperial/DocumentNotFound.ts similarity index 100% rename from src/lib/errors/HTTPErrors/DocumentNotFound.ts rename to src/lib/errors/Imperial/DocumentNotFound.ts diff --git a/src/lib/errors/HTTPErrors/NotAllowed.ts b/src/lib/errors/Imperial/EditNotAllowed.ts similarity index 100% rename from src/lib/errors/HTTPErrors/NotAllowed.ts rename to src/lib/errors/Imperial/EditNotAllowed.ts diff --git a/src/lib/errors/Imperial/WrongPassword.ts b/src/lib/errors/Imperial/WrongPassword.ts new file mode 100644 index 0000000..a1f43d9 --- /dev/null +++ b/src/lib/errors/Imperial/WrongPassword.ts @@ -0,0 +1,10 @@ +import { ImperialError } from "../ImperialError"; + +export class WrongPassword extends ImperialError { + constructor(...args: ConstructorParameters) { + super(...args); + + this.message = "You need to provide a password, since this document is encrypted!"; + this.status = 401; + } +} diff --git a/src/lib/errors/index.ts b/src/lib/errors/index.ts index 9422cef..afc0635 100644 --- a/src/lib/errors/index.ts +++ b/src/lib/errors/index.ts @@ -1,5 +1,6 @@ -export { DocumentNotFound } from "./HTTPErrors/DocumentNotFound"; -export { NotAllowed } from "./HTTPErrors/NotAllowed"; +export { DocumentNotFound } from "./Imperial/DocumentNotFound"; export { ImperialError } from "./ImperialError"; export { Aborted } from "./HTTPErrors/Aborted"; export { FailedToFetch } from "./HTTPErrors/FailedToFetch"; +export { NotAllowed } from "./Imperial/EditNotAllowed"; +export { WrongPassword } from "./Imperial/WrongPassword";