110 lines
3.7 KiB
TypeScript
110 lines
3.7 KiB
TypeScript
/*! firebase-admin v14.0.0 */
|
|
/*!
|
|
* @license
|
|
* Copyright 2017 Google LLC
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
/**
|
|
* Represents the raw HTTP response object.
|
|
*/
|
|
export interface HttpResponse {
|
|
/** The HTTP status code of the response. */
|
|
status: number;
|
|
/** The HTTP headers of the response. */
|
|
headers: {
|
|
[key: string]: any;
|
|
};
|
|
/** The response data payload. */
|
|
data?: string | object;
|
|
}
|
|
/**
|
|
* Defines error info type. This includes a code and message string.
|
|
*/
|
|
export interface ErrorInfo {
|
|
/** The string error code. */
|
|
code: string;
|
|
/** The error message. */
|
|
message: string;
|
|
/** The HTTP response associated with this error, if any. */
|
|
httpResponse?: HttpResponse;
|
|
/** The original wrapped error that triggered this error, if any. */
|
|
cause?: Error;
|
|
}
|
|
/**
|
|
* `FirebaseError` is a subclass of the standard JavaScript `Error` object. In
|
|
* addition to a message string and stack trace, it contains a string code.
|
|
*/
|
|
export interface FirebaseError {
|
|
/**
|
|
* Error codes are strings using the following format: `"service/string-code"`.
|
|
* Some examples include `"auth/invalid-uid"` and
|
|
* `"messaging/invalid-recipient"`.
|
|
*
|
|
* While the message for a given error can change, the code will remain the same
|
|
* between backward-compatible versions of the Firebase SDK.
|
|
*/
|
|
code: string;
|
|
/**
|
|
* An explanatory message for the error that just occurred.
|
|
*
|
|
* This message is designed to be helpful to you, the developer. Because
|
|
* it generally does not convey meaningful information to end users,
|
|
* this message should not be displayed in your application.
|
|
*/
|
|
message: string;
|
|
/**
|
|
* A string value containing the execution backtrace when the error originally
|
|
* occurred.
|
|
*
|
|
* This information can be useful for troubleshooting the cause of the error with
|
|
* {@link https://firebase.google.com/support | Firebase Support}.
|
|
*/
|
|
stack?: string;
|
|
/**
|
|
* The HTTP response associated with this error, if any.
|
|
*/
|
|
httpResponse?: HttpResponse;
|
|
/**
|
|
* The original wrapped error that triggered this error, if any.
|
|
*/
|
|
cause?: Error;
|
|
/**
|
|
* Checks if this error matches the specified error code.
|
|
*
|
|
* This method enables checking the error type without needing to account for
|
|
* service-specific code prefixes. For example, if this error has the code
|
|
* `"auth/invalid-uid"`, calling `err.hasCode('invalid-uid')` or
|
|
* `err.hasCode('auth/invalid-uid')` will both return `true`.
|
|
*
|
|
* @param code - The error code to test against (either non-prefixed or fully qualified).
|
|
* @returns True if the error code matches, false otherwise.
|
|
*/
|
|
hasCode(code: string): boolean;
|
|
/**
|
|
* Returns a JSON-serializable object representation of this error.
|
|
*
|
|
* @returns A JSON-serializable representation of this object.
|
|
*/
|
|
toJSON(): object;
|
|
}
|
|
/**
|
|
* Firebase error code structure. This extends Error.
|
|
*/
|
|
export declare class FirebaseError extends Error implements FirebaseError {
|
|
/**
|
|
* @param errorInfo - The error information (code and message).
|
|
*/
|
|
constructor(errorInfo: ErrorInfo);
|
|
}
|