From e795419b78520cc637cf9d4bda0ab76ccd8b6353 Mon Sep 17 00:00:00 2001 From: sianida26 Date: Fri, 22 Mar 2024 01:21:13 +0700 Subject: [PATCH] Added File Error --- src/core/error/FileError.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/core/error/FileError.ts diff --git a/src/core/error/FileError.ts b/src/core/error/FileError.ts new file mode 100644 index 0000000..2acd73c --- /dev/null +++ b/src/core/error/FileError.ts @@ -0,0 +1,26 @@ +import BaseError from "@/core/error/BaseError"; + +export const FileErrorCodes = [ + "INVALID_IMAGE_FORMAT", + "IMAGE_TOO_LARGE", +] as const; + +interface FileErrorOptions { + message?: string; + errorCode: (typeof FileErrorCodes)[number] | (string & {}); + statusCode?: number; +} + +export default class FileError extends BaseError { + errorCode: (typeof FileErrorCodes)[number] | (string & {}); + + constructor(options: FileErrorOptions) { + super({ + errorCode: options.errorCode, + message: options.message, + statusCode: options.statusCode, + }); + + this.errorCode = options.errorCode; + } +}