UNPKG

fayda-auth

Version:

A library for interacting with the Fayda authentication service.

21 lines (18 loc) 596 B
import { ApiError, ErrorDetails } from "./types"; /** * Custom error class for Fayda Auth API errors. */ export class FaydaAuthError extends Error { public readonly code: string; public readonly statusCode: number; public readonly details?: ErrorDetails; public readonly timestamp: string; constructor(apiError: ApiError) { super(apiError.message); this.name = 'FaydaAuthError'; this.code = apiError.error; this.statusCode = apiError.statusCode; this.details = apiError.details; this.timestamp = apiError.timestamp; } }