import { P2PPeerInfo } from './types' ; export class PeerInboundHandshakeError extends Error { public statusCode : number ; public remoteAddress : string ; public handshakeURL ? : string ; public constructor ( message , statusCode , remoteAddress , handshakeURL ? ) { super ( message ) ; this . name = 'PeerInboundHandshakeError' ; this . statusCode = statusCode ; this . remoteAddress = remoteAddress ; this . handshakeURL = handshakeURL ; } } export class PeerInboundDuplicateConnectionError extends Error { public peerId : string ; public constructor ( message , peerId ) { super ( message ) ; this . name = 'PeerInboundDuplicateConnectionError' ; this . peerId = peerId ; } } export class RPCResponseError extends Error { public peerId : string ; public constructor ( message , peerId ) { super ( message ) ; this . name = 'RPCResponseError' ; this . peerId = peerId ; } } export class InvalidRPCResponseError extends Error { public constructor ( message ) { super ( message ) ; this . name = 'InvalidRPCResponseError' ; } } export class RPCResponseAlreadySentError extends Error { public constructor ( message ) { super ( message ) ; this . name = 'ResponseAlreadySentError' ; } } export class ExistingPeerError extends Error { public peerInfo : P2PPeerInfo ; public constructor ( peerInfo ) { super ( 'Peer already exists' ) ; this . name = 'ExistingPeerError' ; this . peerInfo = peerInfo ; } } export class InvalidNodeInfoError extends Error { public constructor ( message ) { super ( message ) ; this . name = 'InvalidNodeInfoError' ; } } export class InvalidPeerInfoError extends Error { public constructor ( message ) { super ( message ) ; this . name = 'InvalidPeerInfoError' ; } } export class InvalidPeerInfoListError extends Error { public constructor ( message ) { super ( message ) ; this . name = 'InvalidPeerInfoListError' ; } } export class RequestFailError extends Error { public peerId : string ; public peerVersion : string ; public response : Error ; public constructor ( message , response ? , peerId ? , peerVersion ? ) { super ( message ) ; this . name = 'RequestFailError' ; this . response = response ?? new Error ( message ) ; this . peerId = peerId ?? '' ; this . peerVersion = peerVersion ?? '' ; this . message = peerId ? `${ this . message }: Peer Id: ${ this . peerId }: Peer Version: ${ this . peerVersion }` : message ; } } export class SendFailError extends Error { public constructor ( message ) { super ( message ) ; this . name = 'SendFailError' ; } } export class InvalidRPCRequestError extends Error { public constructor ( message ) { super ( message ) ; this . name = 'InvalidRPCRequestError' ; } } export class InvalidProtocolMessageError extends Error { public constructor ( message ) { super ( message ) ; this . name = 'InvalidProtocolMessageError' ; } } export class InvalidPayloadError extends Error { public parsedMessage : object ; public constructor ( message , parsedMessage ) { super ( message ) ; this . name = 'InvalidPayloadError' ; this . parsedMessage = parsedMessage ; } } export class InvalidDisconnectEventError extends Error { public constructor ( message ) { super ( message ) ; this . name = 'InvalidDisconnectEventError' ; } }