@@ -21,10 +21,10 @@ import { CONFIG_STORAGE_BUCKET_KEY } from './constants';
21
21
* An error returned by the Firebase Storage SDK.
22
22
* @public
23
23
*/
24
- export class FirebaseStorageError extends FirebaseError {
24
+ export class StorageError extends FirebaseError {
25
25
private readonly _baseMessage : string ;
26
26
/**
27
- * Stores custom error data unque to FirebaseStorageError .
27
+ * Stores custom error data unque to StorageError .
28
28
*/
29
29
customData : { serverResponse : string | null } = { serverResponse : null } ;
30
30
@@ -39,9 +39,9 @@ export class FirebaseStorageError extends FirebaseError {
39
39
`Firebase Storage: ${ message } (${ prependCode ( code ) } )`
40
40
) ;
41
41
this . _baseMessage = this . message ;
42
- // Without this, `instanceof FirebaseStorageError `, in tests for example,
42
+ // Without this, `instanceof StorageError `, in tests for example,
43
43
// returns false.
44
- Object . setPrototypeOf ( this , FirebaseStorageError . prototype ) ;
44
+ Object . setPrototypeOf ( this , StorageError . prototype ) ;
45
45
}
46
46
47
47
/**
@@ -72,7 +72,7 @@ export const errors = {};
72
72
73
73
/**
74
74
* @public
75
- * Error codes that can be attached to `FirebaseStorageError `s.
75
+ * Error codes that can be attached to `StorageError `s.
76
76
*/
77
77
export const enum StorageErrorCode {
78
78
// Shared between all platforms
@@ -108,36 +108,36 @@ export function prependCode(code: StorageErrorCode): string {
108
108
return 'storage/' + code ;
109
109
}
110
110
111
- export function unknown ( ) : FirebaseStorageError {
111
+ export function unknown ( ) : StorageError {
112
112
const message =
113
113
'An unknown error occurred, please check the error payload for ' +
114
114
'server response.' ;
115
- return new FirebaseStorageError ( StorageErrorCode . UNKNOWN , message ) ;
115
+ return new StorageError ( StorageErrorCode . UNKNOWN , message ) ;
116
116
}
117
117
118
- export function objectNotFound ( path : string ) : FirebaseStorageError {
119
- return new FirebaseStorageError (
118
+ export function objectNotFound ( path : string ) : StorageError {
119
+ return new StorageError (
120
120
StorageErrorCode . OBJECT_NOT_FOUND ,
121
121
"Object '" + path + "' does not exist."
122
122
) ;
123
123
}
124
124
125
- export function bucketNotFound ( bucket : string ) : FirebaseStorageError {
126
- return new FirebaseStorageError (
125
+ export function bucketNotFound ( bucket : string ) : StorageError {
126
+ return new StorageError (
127
127
StorageErrorCode . BUCKET_NOT_FOUND ,
128
128
"Bucket '" + bucket + "' does not exist."
129
129
) ;
130
130
}
131
131
132
- export function projectNotFound ( project : string ) : FirebaseStorageError {
133
- return new FirebaseStorageError (
132
+ export function projectNotFound ( project : string ) : StorageError {
133
+ return new StorageError (
134
134
StorageErrorCode . PROJECT_NOT_FOUND ,
135
135
"Project '" + project + "' does not exist."
136
136
) ;
137
137
}
138
138
139
- export function quotaExceeded ( bucket : string ) : FirebaseStorageError {
140
- return new FirebaseStorageError (
139
+ export function quotaExceeded ( bucket : string ) : StorageError {
140
+ return new StorageError (
141
141
StorageErrorCode . QUOTA_EXCEEDED ,
142
142
"Quota for bucket '" +
143
143
bucket +
@@ -146,29 +146,29 @@ export function quotaExceeded(bucket: string): FirebaseStorageError {
146
146
) ;
147
147
}
148
148
149
- export function unauthenticated ( ) : FirebaseStorageError {
149
+ export function unauthenticated ( ) : StorageError {
150
150
const message =
151
151
'User is not authenticated, please authenticate using Firebase ' +
152
152
'Authentication and try again.' ;
153
- return new FirebaseStorageError ( StorageErrorCode . UNAUTHENTICATED , message ) ;
153
+ return new StorageError ( StorageErrorCode . UNAUTHENTICATED , message ) ;
154
154
}
155
155
156
- export function unauthorizedApp ( ) : FirebaseStorageError {
157
- return new FirebaseStorageError (
156
+ export function unauthorizedApp ( ) : StorageError {
157
+ return new StorageError (
158
158
StorageErrorCode . UNAUTHORIZED_APP ,
159
159
'This app does not have permission to access Firebase Storage on this project.'
160
160
) ;
161
161
}
162
162
163
- export function unauthorized ( path : string ) : FirebaseStorageError {
164
- return new FirebaseStorageError (
163
+ export function unauthorized ( path : string ) : StorageError {
164
+ return new StorageError (
165
165
StorageErrorCode . UNAUTHORIZED ,
166
166
"User does not have permission to access '" + path + "'."
167
167
) ;
168
168
}
169
169
170
- export function retryLimitExceeded ( ) : FirebaseStorageError {
171
- return new FirebaseStorageError (
170
+ export function retryLimitExceeded ( ) : StorageError {
171
+ return new StorageError (
172
172
StorageErrorCode . RETRY_LIMIT_EXCEEDED ,
173
173
'Max retry time for operation exceeded, please try again.'
174
174
) ;
@@ -178,8 +178,8 @@ export function invalidChecksum(
178
178
path : string ,
179
179
checksum : string ,
180
180
calculated : string
181
- ) : FirebaseStorageError {
182
- return new FirebaseStorageError (
181
+ ) : StorageError {
182
+ return new StorageError (
183
183
StorageErrorCode . INVALID_CHECKSUM ,
184
184
"Uploaded/downloaded object '" +
185
185
path +
@@ -191,36 +191,36 @@ export function invalidChecksum(
191
191
) ;
192
192
}
193
193
194
- export function canceled ( ) : FirebaseStorageError {
195
- return new FirebaseStorageError (
194
+ export function canceled ( ) : StorageError {
195
+ return new StorageError (
196
196
StorageErrorCode . CANCELED ,
197
197
'User canceled the upload/download.'
198
198
) ;
199
199
}
200
200
201
- export function invalidEventName ( name : string ) : FirebaseStorageError {
202
- return new FirebaseStorageError (
201
+ export function invalidEventName ( name : string ) : StorageError {
202
+ return new StorageError (
203
203
StorageErrorCode . INVALID_EVENT_NAME ,
204
204
"Invalid event name '" + name + "'."
205
205
) ;
206
206
}
207
207
208
- export function invalidUrl ( url : string ) : FirebaseStorageError {
209
- return new FirebaseStorageError (
208
+ export function invalidUrl ( url : string ) : StorageError {
209
+ return new StorageError (
210
210
StorageErrorCode . INVALID_URL ,
211
211
"Invalid URL '" + url + "'."
212
212
) ;
213
213
}
214
214
215
- export function invalidDefaultBucket ( bucket : string ) : FirebaseStorageError {
216
- return new FirebaseStorageError (
215
+ export function invalidDefaultBucket ( bucket : string ) : StorageError {
216
+ return new StorageError (
217
217
StorageErrorCode . INVALID_DEFAULT_BUCKET ,
218
218
"Invalid default bucket '" + bucket + "'."
219
219
) ;
220
220
}
221
221
222
- export function noDefaultBucket ( ) : FirebaseStorageError {
223
- return new FirebaseStorageError (
222
+ export function noDefaultBucket ( ) : StorageError {
223
+ return new StorageError (
224
224
StorageErrorCode . NO_DEFAULT_BUCKET ,
225
225
'No default bucket ' +
226
226
"found. Did you set the '" +
@@ -229,22 +229,22 @@ export function noDefaultBucket(): FirebaseStorageError {
229
229
) ;
230
230
}
231
231
232
- export function cannotSliceBlob ( ) : FirebaseStorageError {
233
- return new FirebaseStorageError (
232
+ export function cannotSliceBlob ( ) : StorageError {
233
+ return new StorageError (
234
234
StorageErrorCode . CANNOT_SLICE_BLOB ,
235
235
'Cannot slice blob for upload. Please retry the upload.'
236
236
) ;
237
237
}
238
238
239
- export function serverFileWrongSize ( ) : FirebaseStorageError {
240
- return new FirebaseStorageError (
239
+ export function serverFileWrongSize ( ) : StorageError {
240
+ return new StorageError (
241
241
StorageErrorCode . SERVER_FILE_WRONG_SIZE ,
242
242
'Server recorded incorrect upload file size, please retry the upload.'
243
243
) ;
244
244
}
245
245
246
- export function noDownloadURL ( ) : FirebaseStorageError {
247
- return new FirebaseStorageError (
246
+ export function noDownloadURL ( ) : StorageError {
247
+ return new StorageError (
248
248
StorageErrorCode . NO_DOWNLOAD_URL ,
249
249
'The given file does not have any download URLs.'
250
250
) ;
@@ -253,16 +253,16 @@ export function noDownloadURL(): FirebaseStorageError {
253
253
/**
254
254
* @internal
255
255
*/
256
- export function invalidArgument ( message : string ) : FirebaseStorageError {
257
- return new FirebaseStorageError ( StorageErrorCode . INVALID_ARGUMENT , message ) ;
256
+ export function invalidArgument ( message : string ) : StorageError {
257
+ return new StorageError ( StorageErrorCode . INVALID_ARGUMENT , message ) ;
258
258
}
259
259
260
260
export function invalidArgumentCount (
261
261
argMin : number ,
262
262
argMax : number ,
263
263
fnName : string ,
264
264
real : number
265
- ) : FirebaseStorageError {
265
+ ) : StorageError {
266
266
let countPart ;
267
267
let plural ;
268
268
if ( argMin === argMax ) {
@@ -272,7 +272,7 @@ export function invalidArgumentCount(
272
272
countPart = 'between ' + argMin + ' and ' + argMax ;
273
273
plural = 'arguments' ;
274
274
}
275
- return new FirebaseStorageError (
275
+ return new StorageError (
276
276
StorageErrorCode . INVALID_ARGUMENT_COUNT ,
277
277
'Invalid argument count in `' +
278
278
fnName +
@@ -286,8 +286,8 @@ export function invalidArgumentCount(
286
286
) ;
287
287
}
288
288
289
- export function appDeleted ( ) : FirebaseStorageError {
290
- return new FirebaseStorageError (
289
+ export function appDeleted ( ) : StorageError {
290
+ return new StorageError (
291
291
StorageErrorCode . APP_DELETED ,
292
292
'The Firebase app was deleted.'
293
293
) ;
@@ -298,8 +298,8 @@ export function appDeleted(): FirebaseStorageError {
298
298
*
299
299
* @internal
300
300
*/
301
- export function invalidRootOperation ( name : string ) : FirebaseStorageError {
302
- return new FirebaseStorageError (
301
+ export function invalidRootOperation ( name : string ) : StorageError {
302
+ return new StorageError (
303
303
StorageErrorCode . INVALID_ROOT_OPERATION ,
304
304
"The operation '" +
305
305
name +
@@ -315,8 +315,8 @@ export function invalidRootOperation(name: string): FirebaseStorageError {
315
315
export function invalidFormat (
316
316
format : string ,
317
317
message : string
318
- ) : FirebaseStorageError {
319
- return new FirebaseStorageError (
318
+ ) : StorageError {
319
+ return new StorageError (
320
320
StorageErrorCode . INVALID_FORMAT ,
321
321
"String does not match format '" + format + "': " + message
322
322
) ;
@@ -325,8 +325,8 @@ export function invalidFormat(
325
325
/**
326
326
* @param message - A message describing the internal error.
327
327
*/
328
- export function unsupportedEnvironment ( message : string ) : FirebaseStorageError {
329
- throw new FirebaseStorageError (
328
+ export function unsupportedEnvironment ( message : string ) : StorageError {
329
+ throw new StorageError (
330
330
StorageErrorCode . UNSUPPORTED_ENVIRONMENT ,
331
331
message
332
332
) ;
@@ -335,8 +335,8 @@ export function unsupportedEnvironment(message: string): FirebaseStorageError {
335
335
/**
336
336
* @param message - A message describing the internal error.
337
337
*/
338
- export function internalError ( message : string ) : FirebaseStorageError {
339
- throw new FirebaseStorageError (
338
+ export function internalError ( message : string ) : StorageError {
339
+ throw new StorageError (
340
340
StorageErrorCode . INTERNAL_ERROR ,
341
341
'Internal error: ' + message
342
342
) ;
0 commit comments