import { DetailsError } from './DetailsError' ; import { ServerErrorType , ServerInternalError } from './ServerInternalError' ; export interface IErrorDetails { name : string ; message : string ; hasDetails : boolean ; errorType ? : ServerErrorType ; } export function hasDetails ( error ) { return error instanceof DetailsError && error . hasDetails ( ) ; } export function getErrorDetails ( error ) { const exceptionMessage = hasDetails ( error ) ? error . errorMessage : error . message || error . name ; const details = { name : error . name , message : exceptionMessage , hasDetails : hasDetails ( error ) , } ; if ( error instanceof ServerInternalError && error . errorType ) { details . errorType = error . errorType ; if ( error . errorType === ServerErrorType . QUOTE_EXCEEDED ) { details . hasDetails = false ; } } return details ; }