@cloudbase/storage 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,43 @@
1
+ export class StorageError extends Error {
2
+ protected __isStorageError = true
3
+
4
+ constructor(message: string) {
5
+ super(message)
6
+ this.name = 'StorageError'
7
+ }
8
+ }
9
+
10
+ export function isStorageError(error: unknown): error is StorageError {
11
+ return typeof error === 'object' && error !== null && '__isStorageError' in error
12
+ }
13
+
14
+ export class StorageApiError extends StorageError {
15
+ status: number
16
+ statusCode: string
17
+
18
+ constructor(message: string, status: number, statusCode: string) {
19
+ super(message)
20
+ this.name = 'StorageApiError'
21
+ this.status = status
22
+ this.statusCode = statusCode
23
+ }
24
+
25
+ toJSON() {
26
+ return {
27
+ name: this.name,
28
+ message: this.message,
29
+ status: this.status,
30
+ statusCode: this.statusCode,
31
+ }
32
+ }
33
+ }
34
+
35
+ export class StorageUnknownError extends StorageError {
36
+ originalError: unknown
37
+
38
+ constructor(message: string, originalError: unknown) {
39
+ super(message)
40
+ this.name = 'StorageUnknownError'
41
+ this.originalError = originalError
42
+ }
43
+ }