-
Notifications
You must be signed in to change notification settings - Fork 938
Export StorageError class instead of interface #6974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
928e33e
1095d7b
9eedf81
18f7b07
58fbc42
df7d9e1
24f3912
0290cdb
11e5d43
5585cdf
7476d35
89c4478
2312460
332cf31
f7dd97d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"firebase": minor | ||
"@firebase/storage": minor | ||
--- | ||
|
||
Fixed issue where users were unable to check if an Error was an instance of `StorageError`. |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -134,13 +134,11 @@ export function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStora | |||
// @public | ||||
export function getStream(ref: StorageReference, maxDownloadSizeBytes?: number): NodeJS.ReadableStream; | ||||
|
||||
// Warning: (ae-forgotten-export) The symbol "StorageError" needs to be exported by the entry point index.d.ts | ||||
// | ||||
// @internal (undocumented) | ||||
export function _invalidArgument(message: string): StorageError_2; | ||||
export function _invalidArgument(message: string): StorageError; | ||||
|
||||
// @internal (undocumented) | ||||
export function _invalidRootOperation(name: string): StorageError_2; | ||||
export function _invalidRootOperation(name: string): StorageError; | ||||
|
||||
// @public | ||||
export function list(ref: StorageReference, options?: ListOptions): Promise<ListResult>; | ||||
|
@@ -217,8 +215,71 @@ export interface SettableMetadata { | |||
} | ||||
|
||||
// @public | ||||
export interface StorageError extends FirebaseError { | ||||
serverResponse: string | null; | ||||
export class StorageError extends FirebaseError { | ||||
constructor(code: StorageErrorCode, message: string, status_?: number); | ||||
_codeEquals(code: StorageErrorCode): boolean; | ||||
customData: { | ||||
serverResponse: string | null; | ||||
}; | ||||
get serverResponse(): null | string; | ||||
set serverResponse(serverResponse: string | null); | ||||
// (undocumented) | ||||
get status(): number; | ||||
set status(status: number); | ||||
} | ||||
|
||||
// @public | ||||
export const enum StorageErrorCode { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, wasn't paying attention earlier to a new enum being exported as well, I think there are some problems with exporting a
Background on const enum issues https://ncjamieson.com/dont-export-const-enums/ |
||||
// (undocumented) | ||||
APP_DELETED = "app-deleted", | ||||
// (undocumented) | ||||
BUCKET_NOT_FOUND = "bucket-not-found", | ||||
// (undocumented) | ||||
CANCELED = "canceled", | ||||
// (undocumented) | ||||
CANNOT_SLICE_BLOB = "cannot-slice-blob", | ||||
// (undocumented) | ||||
INTERNAL_ERROR = "internal-error", | ||||
// (undocumented) | ||||
INVALID_ARGUMENT = "invalid-argument", | ||||
// (undocumented) | ||||
INVALID_ARGUMENT_COUNT = "invalid-argument-count", | ||||
// (undocumented) | ||||
INVALID_CHECKSUM = "invalid-checksum", | ||||
// (undocumented) | ||||
INVALID_DEFAULT_BUCKET = "invalid-default-bucket", | ||||
// (undocumented) | ||||
INVALID_EVENT_NAME = "invalid-event-name", | ||||
// (undocumented) | ||||
INVALID_FORMAT = "invalid-format", | ||||
// (undocumented) | ||||
INVALID_ROOT_OPERATION = "invalid-root-operation", | ||||
// (undocumented) | ||||
INVALID_URL = "invalid-url", | ||||
// (undocumented) | ||||
NO_DEFAULT_BUCKET = "no-default-bucket", | ||||
// (undocumented) | ||||
NO_DOWNLOAD_URL = "no-download-url", | ||||
// (undocumented) | ||||
OBJECT_NOT_FOUND = "object-not-found", | ||||
// (undocumented) | ||||
PROJECT_NOT_FOUND = "project-not-found", | ||||
// (undocumented) | ||||
QUOTA_EXCEEDED = "quota-exceeded", | ||||
// (undocumented) | ||||
RETRY_LIMIT_EXCEEDED = "retry-limit-exceeded", | ||||
// (undocumented) | ||||
SERVER_FILE_WRONG_SIZE = "server-file-wrong-size", | ||||
// (undocumented) | ||||
UNAUTHENTICATED = "unauthenticated", | ||||
// (undocumented) | ||||
UNAUTHORIZED = "unauthorized", | ||||
// (undocumented) | ||||
UNAUTHORIZED_APP = "unauthorized-app", | ||||
// (undocumented) | ||||
UNKNOWN = "unknown", | ||||
// (undocumented) | ||||
UNSUPPORTED_ENVIRONMENT = "unsupported-environment" | ||||
} | ||||
|
||||
// @public | ||||
|
@@ -318,20 +379,20 @@ export class _UploadTask { | |||
constructor(ref: _Reference, blob: _FbsBlob, metadata?: Metadata | null); | ||||
_blob: _FbsBlob; | ||||
cancel(): boolean; | ||||
catch<T>(onRejected: (p1: StorageError_2) => T | Promise<T>): Promise<T>; | ||||
catch<T>(onRejected: (p1: StorageError) => T | Promise<T>): Promise<T>; | ||||
// (undocumented) | ||||
isExponentialBackoffExpired(): boolean; | ||||
// Warning: (ae-forgotten-export) The symbol "Metadata" needs to be exported by the entry point index.d.ts | ||||
_metadata: Metadata | null; | ||||
// Warning: (ae-forgotten-export) The symbol "Unsubscribe" needs to be exported by the entry point index.d.ts | ||||
// Warning: (ae-forgotten-export) The symbol "Subscribe" needs to be exported by the entry point index.d.ts | ||||
on(type: _TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError_2) => unknown) | null, completed?: CompleteFn | null): Unsubscribe_2 | Subscribe_2<UploadTaskSnapshot>; | ||||
on(type: _TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, completed?: CompleteFn | null): Unsubscribe_2 | Subscribe_2<UploadTaskSnapshot>; | ||||
pause(): boolean; | ||||
resume(): boolean; | ||||
get snapshot(): UploadTaskSnapshot; | ||||
// Warning: (ae-forgotten-export) The symbol "InternalTaskState" needs to be exported by the entry point index.d.ts | ||||
_state: InternalTaskState; | ||||
then<U>(onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null, onRejected?: ((error: StorageError_2) => U | Promise<U>) | null): Promise<U>; | ||||
then<U>(onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null, onRejected?: ((error: StorageError) => U | Promise<U>) | null): Promise<U>; | ||||
_transferred: number; | ||||
} | ||||
|
||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,10 @@ | |
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { FirebaseApp, _FirebaseService } from '@firebase/app'; | ||
import { | ||
CompleteFn, | ||
FirebaseError, | ||
NextFn, | ||
Subscribe, | ||
Unsubscribe | ||
} from '@firebase/util'; | ||
import { CompleteFn, NextFn, Subscribe, Unsubscribe } from '@firebase/util'; | ||
import { StorageError } from './implementation/error'; | ||
maneesht marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export { StorageError, StorageErrorCode } from './implementation/error'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be exported directly from |
||
|
||
/** | ||
* A Firebase Storage instance. | ||
|
@@ -249,17 +246,6 @@ export type TaskEvent = 'state_changed'; | |
*/ | ||
export type TaskState = 'running' | 'paused' | 'success' | 'canceled' | 'error'; | ||
|
||
/** | ||
* An error returned by the Firebase Storage SDK. | ||
* @public | ||
*/ | ||
export interface StorageError extends FirebaseError { | ||
/** | ||
* A server response message for the error, if applicable. | ||
*/ | ||
serverResponse: string | null; | ||
} | ||
|
||
/** | ||
* A stream observer for Firebase Storage. | ||
* @public | ||
|
Uh oh!
There was an error while loading. Please reload this page.