import { AlertExecutionStatusErrorReasons } from '../types' ; export class ErrorWithReason extends Error { public readonly reason : AlertExecutionStatusErrorReasons ; public readonly error : Error ; constructor ( reason , error ) { super ( error . message ) ; this . error = error ; this . reason = reason ; } } export function getReasonFromError ( error ) { if ( isErrorWithReason ( error ) ) { return error . reason ; } return AlertExecutionStatusErrorReasons . Unknown ; } export function isErrorWithReason ( error ) { return error instanceof ErrorWithReason ; }