PostcodeError
The error that each call of PostcodeClient raises when it cannot give a result. A
cancelled call raises the platform’s own abort error instead.
Example
Section titled “Example”import { PostcodeClient, PostcodeError } from '@gatepost/client';
const client = new PostcodeClient({ apiKey: process.env['NIPOST_API_KEY'] });try { await client.lookup('FC-01-Z99');} catch (error) { if (error instanceof PostcodeError) { error.code; // 'invalid_input' error.status; // null }}Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PostcodeError(
code,message,details?):PostcodeError
Makes an error. The client makes each one. A test of code that uses the client can make one too.
Parameters
Section titled “Parameters”Why the call failed.
message
Section titled “message”string
What happened and what to do, with no API key in it.
details?
Section titled “details?”Readonly<{ apiCode?: string | null; cause?: unknown; retryAfterMs?: number | null; status?: number | null; }> = {}
The status, the apiCode, the retryAfterMs and the cause. Each one
that is missing is null.
Returns
Section titled “Returns”PostcodeError
Overrides
Section titled “Overrides”Error.constructor
Properties
Section titled “Properties”apiCode
Section titled “apiCode”
readonlyapiCode:string|null
The error.code of the response body, or null.
readonlycode:PostcodeErrorCode
Why the call failed, as a stable code.
readonlyname:string='PostcodeError'
Always PostcodeError, so that a log names the error type.
Overrides
Section titled “Overrides”Error.name
retryAfterMs
Section titled “retryAfterMs”
readonlyretryAfterMs:number|null
The wait that Retry-After asked for, in milliseconds, or null.
status
Section titled “status”
readonlystatus:number|null
The HTTP status of the response, or null when no response arrived.
Unofficial. Not made or endorsed by NIPOST.