diff --git a/src/lib/errors.ts b/src/lib/errors.ts index dabef49..c0d26df 100644 --- a/src/lib/errors.ts +++ b/src/lib/errors.ts @@ -12,19 +12,19 @@ export function isStorageError(error: unknown): error is StorageError { } export class StorageApiError extends StorageError { - status: number + statusCode: string - constructor(message: string, status: number) { + constructor(message: string, statusCode: string) { super(message) this.name = 'StorageApiError' - this.status = status + this.statusCode = statusCode } toJSON() { return { name: this.name, message: this.message, - status: this.status, + statusCode: this.statusCode, } } } diff --git a/src/lib/fetch.ts b/src/lib/fetch.ts index 2bf5d72..9110657 100644 --- a/src/lib/fetch.ts +++ b/src/lib/fetch.ts @@ -27,7 +27,7 @@ const handleError = async ( error .json() .then((err) => { - reject(new StorageApiError(_getErrorMessage(err), error.status || 500)) + reject(new StorageApiError(_getErrorMessage(err), error.status.toString() || '500')) }) .catch((err) => { reject(new StorageUnknownError(_getErrorMessage(err), err))