import { EphemeralTask } from '../task' ; const CODE_UNRECOVERABLE = 'TaskManager/unrecoverable' ; const code = Symbol ( 'TaskManagerErrorCode' ) ; export interface DecoratedError extends Error { [ code ] ? : string ; } export class EphemeralTaskRejectedDueToCapacityError extends Error { private _task : EphemeralTask ; constructor ( message , task ) { super ( message ) ; this . _task = task ; } public get task ( ) { return this . _task ; } } function isTaskManagerError ( error ) { return Boolean ( error && ( error as DecoratedError ) [ code ] ) ; } export function isUnrecoverableError ( error ) { return isTaskManagerError ( error ) && error [ code ] === CODE_UNRECOVERABLE ; } export function throwUnrecoverableError ( error ) { ( error as DecoratedError ) [ code ] = CODE_UNRECOVERABLE ; throw error ; } export function isEphemeralTaskRejectedDueToCapacityError ( error ) { return Boolean ( error && error instanceof EphemeralTaskRejectedDueToCapacityError ) ; }