Skip to content

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

Merged
merged 15 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/hungry-glasses-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"firebase": minor
"@firebase/storage": minor
---

Export StorageError class instead of interface
28 changes: 18 additions & 10 deletions common/api-review/storage.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down Expand Up @@ -217,9 +215,19 @@ export interface SettableMetadata {
}

// @public
export interface StorageError extends FirebaseError {
serverResponse: string | null;
}
export class StorageError extends FirebaseError {
// Warning: (ae-forgotten-export) The symbol "StorageErrorCode" needs to be exported by the entry point index.d.ts
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 interface StorageObserver<T> {
Expand Down Expand Up @@ -318,20 +326,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;
}

Expand Down
22 changes: 4 additions & 18 deletions packages/storage/src/public-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

export { StorageError } from './implementation/error';

/**
* A Firebase Storage instance.
Expand Down Expand Up @@ -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
Expand Down