export type Values < E > = E [ keyof E ] ; export abstract class EngineError extends Error { static readonly errors = { ChannelError : 'ChannelError' , JoinChannelError : 'JoinChannelError' , CloseChannelError : 'CloseChannelError' , UpdateChannelError : 'UpdateChannelError' , NonceError : 'NonceError' , StoreError : 'StoreError' , OnchainError : 'OnchainError' , PushMessageError : 'PushMessageError' , } as const ; abstract readonly type : Values < typeof EngineError . errors > ; static readonly reasons : { [ key ] : string ; } ; constructor ( public readonly reason , public readonly data = undefined ) { super ( reason ) ; } } function hasOwnProperty < X extends { } , Y extends PropertyKey > ( obj , prop ) { return obj . hasOwnProperty ( prop ) ; } export function isEngineError ( error ) { if ( ! error ?. type ) return false ; if ( ! ( typeof error . type === 'string' || error . type instanceof String ) ) return false ; return hasOwnProperty ( EngineError . errors , error . type ) ; } export class PushMessageError extends EngineError { readonly type = EngineError . errors . PushMessageError ; static readonly reasons = { genericPushMessageError : 'Error during pushMessage' , } as const ; constructor ( reason , public readonly data ) { super ( reason ) ; } }