UNPKG

1.45 kBTypeScriptView Raw
1import { AxiosError } from "axios";
2import * as Errors from "./models/client/Errors";
3/**
4 * Handles general errors and all client request errors.
5 * Client response errors are classified so that proper response error is generated.
6 */
7export declare class ErrorHandler {
8 /**
9 * Process callback function for HTTP request.
10 *
11 * @param error - request error that needs to be transformed to proper Postmark error.
12 *
13 * @return {PostmarkError} - formatted Postmark error
14 */
15 buildRequestError(error: AxiosError): Errors.PostmarkError;
16 /**
17 * Build general Postmark error.
18 *
19 * @param errorMessage - error message that needs to be identified and transformed to proper Postmark error.
20 *
21 * @returns properly formatted Postmark error.
22 */
23 buildGeneralError(errorMessage: string): Errors.PostmarkError;
24 /**
25 * Build Postmark error based on response from http client.
26 *
27 * @param {AxiosResponse} response - request response used to transform to Postmark error.
28 * @return {PostmarkError} - formatted Postmark error
29 */
30 private buildErrorForResponse;
31 private retrieveDefaultOrValue;
32 /**
33 * Build Postmark error based on HTTP request status.
34 *
35 * @param error - http request library error, that will be transformed to Postmark error.
36 *
37 * @returns properly formatted Postmark error.
38 */
39 private buildRequestErrorByStatus;
40}