/** * @module Errors * * @description Exports error classes which may be returned by this client */ import { HttpResponse } from "./agent"; import { components } from "@ideal-postcodes/openapi"; export declare type ApiErrorResponse = components["schemas"]["ErrorResponse"]; /** * IdealPostcodesErrorOptions * * IdealPostcodesError requires only a HTTP status from a failed API request */ interface IdealPostcodesErrorOptions { message: string; httpStatus: number; metadata?: Metadata; } /** * Metadata * * An abitrary object which stores metadata specific to the concrete client * implementation */ interface Metadata { [k: string]: unknown; } /** * IdealPostcodesError * * Base error class for all API responses that return an error. This class * is used where a JSON body is not provided or invalid * E.g. 503 rate limit response, JSON parse failure response */ export declare class IdealPostcodesError extends Error { __proto__: Error; httpStatus: number; metadata: Metadata; /** * Instantiate IdealPostcodesError */ constructor(options: IdealPostcodesErrorOptions); } /** * IdpcApiError * * Base error class for API responses with a JSON body. Typically a subclass * will be used to capture the error category (e.g. 400, 401, 500, etc) */ export declare class IdpcApiError extends IdealPostcodesError { /** * Raw HTTP response */ response: HttpResponse; /** * Returns an API error instance */ constructor(httpResponse: HttpResponse); } /** * IdpcBadRequestError * * Captures API responses that return a 400 (Bad Request Error) response * * Examples include: * - Invalid syntax submitted * - Invalid date range submitted * - Invalid tag submitted */ export declare class IdpcBadRequestError extends IdpcApiError { } /** * IdpcUnauthorisedError * * Captures API responses that return a 401 (Unauthorised) response * * Examples include: * - Invalid api_key * - Invalid user_token * - Invalid licensee */ export declare class IdpcUnauthorisedError extends IdpcApiError { } /** * IpdcInvalidKeyError * * Invalid API Key presented for request */ export declare class IdpcInvalidKeyError extends IdpcUnauthorisedError { } /** * IdpcRequestFailedError * * Captures API responses that return a 402 (Request Failed) response * * Examples include: * - Key balance depleted * - Daily key limit reached */ export declare class IdpcRequestFailedError extends IdpcApiError { } /** * IdpcBalanceDepleted * * Balance on key has been depleted */ export declare class IdpcBalanceDepletedError extends IdpcRequestFailedError { } /** * IdpcLimitReachedError * * Limit reached. One of your lookup limits has been breached for today. This * could either be your total daily limit on your key or the individual IP * limit. You can either wait for for the limit to reset (after a day) or * manually disable or increase your limit. */ export declare class IdpcLimitReachedError extends IdpcRequestFailedError { } /** * IdpcResourceNotFoundError * * Captures API responses that return a 404 (Resource Not Found) response * * Examples include: * - Postcode not found * - UDPRN not found * - Key not found */ export declare class IdpcResourceNotFoundError extends IdpcApiError { } /** * IdpcPostcodeNotFoundError * * Requested postcode does not exist */ export declare class IdpcPostcodeNotFoundError extends IdpcResourceNotFoundError { } /** * IdpcKeyNotFoundError * * Requested API Key does not exist */ export declare class IdpcKeyNotFoundError extends IdpcResourceNotFoundError { } /** * IdpcUdprnNotFoundError * * Requested UDPRN does not exist */ export declare class IdpcUdprnNotFoundError extends IdpcResourceNotFoundError { } /** * IdpcUmprnNotFoundError * * Requested UMPRN does not exist */ export declare class IdpcUmprnNotFoundError extends IdpcResourceNotFoundError { } /** * IdpcServerError * * Captures API responses that return a 500 (Server Error) response */ export declare class IdpcServerError extends IdpcApiError { } /** * parse * * Parses API responses and returns an error for non 2xx responses * * Upon detecting an error an instance of IdealPostcodesError is returned */ export declare const parse: (response: HttpResponse) => Error | void; export {};