UNPKG

1.68 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2017 Google LLC
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17import { FunctionsErrorCodeCore as FunctionsErrorCode } from './public-types';
18import { HttpResponseBody } from './service';
19import { FirebaseError } from '@firebase/util';
20/**
21 * An explicit error that can be thrown from a handler to send an error to the
22 * client that called the function.
23 */
24export declare class FunctionsError extends FirebaseError {
25 /**
26 * Extra data to be converted to JSON and included in the error response.
27 */
28 readonly details?: unknown;
29 constructor(
30 /**
31 * A standard error code that will be returned to the client. This also
32 * determines the HTTP status code of the response, as defined in code.proto.
33 */
34 code: FunctionsErrorCode, message?: string,
35 /**
36 * Extra data to be converted to JSON and included in the error response.
37 */
38 details?: unknown);
39}
40/**
41 * Takes an HTTP response and returns the corresponding Error, if any.
42 */
43export declare function _errorForResponse(status: number, bodyJSON: HttpResponseBody | null): Error | null;