module license import { BaseError } from 'make-error' ; import { ModuleRpcCommon } from '../common' ; /** Base class for all client errors. */ export abstract class ClientError extends BaseError { } /** An error ocurred when providing the request context. */ export class RequestContextError extends ClientError { } /** An error occurred during the decoding of the response context. */ export class ResponseContextDecodingError extends ClientError { } /** The server did not respect the transport protocol. */ export class ClientProtocolError extends ClientError { param url constructor ( readonly url , readonly message ) { super ( `${ url }: ${ message }` ) ; } } /** There has been an error in the transport layer. */ export class ClientTransportError extends ClientError { param cause constructor ( readonly cause ) { super ( `Client transport error: ${ cause . stack || cause . message }` ) ; } } /**
 * A remote error intercepted by the RPC client.  Note that RPC handlers should
 * throw a different error ([[ModuleRpcServer.ServerRpcError]]).  We do this
 * to ensure that no RPC server mistakenly rethrow the RPC error of an upstream
 * service.
 */ export class ClientRpcError < ResponseContext = any > extends ClientError { param errorType param msg param context constructor ( readonly errorType , readonly msg ? , readonly context ? ) { super ( msg ? `Error: ${ ModuleRpcCommon . RpcErrorType [ errorType ] }: ${ JSON . stringify ( msg ) }` : ModuleRpcCommon . RpcErrorType [ errorType ] ) ; } }