type RadixAPIError = { message: string code?: number details?: { type: string } & Record traceId?: string } enum ErrorType { API = 'API', HARDWARE_WALLET = 'HardwareWallet', } type ErrorParams = { [ErrorType.API]: RadixAPIError [ErrorType.HARDWARE_WALLET]: { message: string } } export const radixError = (type: T) => (params: Params) => ({ ...Error(params.message), type, ...params, }) export const radixAPIError = radixError(ErrorType.API) type APIError = ReturnType export const hwWrapper = radixError( ErrorType.HARDWARE_WALLET, ) type HWError = ReturnType export type RadixError = APIError | HWError