import { AxiosError, AxiosResponse } from 'axios'; import { ApiError } from '../../models/errors/ApiError'; import { HttpError } from '../../models/errors/HttpError'; import { IErrorHandler } from '../../types/ErrorHandler'; /** * The base service that handles any errors. * * @public */ export declare class ErrorService implements IErrorHandler { /** * Error message used when the specific error type is not defined in the required enums. */ protected static readonly DEFAULT_ERROR_MESSAGE = "Unknown error"; /** * Creates an API error instance based on the provided error code. * * @param errorCode - The error code. * * @returns An API error instance. */ protected createApiError(errorCode: number): ApiError; /** * Creates an HTTP error instance based on the provided HTTP status. * * @param httpStatus - The HTTP status code. * * @returns An HTTP error instance. */ protected createHttpError(httpStatus: number): HttpError; /** * Retrieves the API error message based on the provided error code. * * @param errorCode - The error code. * * @returns The API error message. */ protected getApiErrorMessage(errorCode: number): string; /** * Retrieves the response data from the given error. * * @param error - The error object. * * @returns The response data. * * @throws The original error if it is not an HTTP error with a response. */ protected getAxiosResponse(error: AxiosError): AxiosResponse; /** * Retrieves the API error code from the Axios response data. * * @param response - The response object received. * * @returns The error code, or undefined if not found. */ protected getErrorCode(response: AxiosResponse): number | undefined; /** * Retrieves the HTTP error message based on the provided HTTP status. * * @param httpStatus - The HTTP status code. * * @returns The HTTP error message. */ protected getHttpErrorMessage(httpStatus: number): string; /** * Handles API error in a response. * * @param response - The response object received. * * @throws An error with the corresponding API error message if any API-related error has occurred. */ protected handleApiError(response: AxiosResponse): void; /** * Handles HTTP error in a response. * * @param response - The response object received. * * @throws An error with the corresponding HTTP status text if any HTTP-related error has occurred. */ protected handleHttpError(response: AxiosResponse): void; /** * Handles exceeded timeout, configured in RettiwtConfig. * * @param error - The error object. * * @throws An error if the configured request timeout has been exceeded. */ protected handleTimeoutError(error: AxiosError): void; /** * The method called when an error response is received from Twitter API. * * @param error - The error caught while making HTTP request to Twitter API. */ handle(error: unknown): void; }