UNPKG

2.43 kBTypeScriptView Raw
1/**
2 * -------------------------------------------------------------------------------------------
3 * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
4 * See License in the project root for license information.
5 * -------------------------------------------------------------------------------------------
6 */
7/**
8 * @module GraphErrorHandler
9 */
10import { GraphError } from "./GraphError";
11import { GraphRequestCallback } from "./IGraphRequestCallback";
12/**
13 * @class
14 * Class for GraphErrorHandler
15 */
16export declare class GraphErrorHandler {
17 /**
18 * @private
19 * @static
20 * Populates the GraphError instance with Error instance values
21 * @param {Error} error - The error returned by graph service or some native error
22 * @param {number} [statusCode] - The status code of the response
23 * @returns The GraphError instance
24 */
25 private static constructError;
26 /**
27 * @private
28 * @static
29 * @async
30 * Populates the GraphError instance from the Error returned by graph service
31 * @param {GraphAPIErrorResponse} graphError - The error possibly returned by graph service or some native error
32 * @param {number} statusCode - The status code of the response
33 * @returns A promise that resolves to GraphError instance
34 *
35 * Example error for https://graph.microsoft.com/v1.0/me/events?$top=3&$search=foo
36 * {
37 * "error": {
38 * "code": "SearchEvents",
39 * "message": "The parameter $search is not currently supported on the Events resource.",
40 * "innerError": {
41 * "request-id": "b31c83fd-944c-4663-aa50-5d9ceb367e19",
42 * "date": "2016-11-17T18:37:45"
43 * }
44 * }
45 * }
46 */
47 private static constructErrorFromResponse;
48 /**
49 * @public
50 * @static
51 * @async
52 * To get the GraphError object
53 * Reference - https://docs.microsoft.com/en-us/graph/errors
54 * @param {any} [error = null] - The error returned by graph service or some native error
55 * @param {number} [statusCode = -1] - The status code of the response
56 * @param {GraphRequestCallback} [callback] - The graph request callback function
57 * @returns A promise that resolves to GraphError instance
58 */
59 static getError(error?: any, statusCode?: number, callback?: GraphRequestCallback): Promise<GraphError>;
60}