UNPKG

@openocean.finance/widget-sdk

Version:

OpenOcean Any-to-Any Cross-Chain-Swap SDK

19 lines (15 loc) 560 B
import { BaseError } from '../baseError.js' import { HTTPError } from '../httpError.js' export const getRootCauseBaseError = (e: Error) => { let rootCause = e while (rootCause.cause && rootCause.cause instanceof BaseError) { rootCause = rootCause.cause as BaseError } return rootCause as BaseError } export const getRootCauseBaseErrorMessage = (e: Error) => { const rootCause = getRootCauseBaseError(e) return rootCause instanceof HTTPError ? (rootCause as HTTPError).responseBody?.message || rootCause.message : rootCause.message }