@@ -6,7 +6,7 @@ import { MessageTypes, MessageTypeNames, Message } from './message-types.js'
66import { createStream } from './stream.js'
77import { toString as uint8ArrayToString } from 'uint8arrays'
88import { logger } from '@libp2p/logger'
9- import errCode from 'err-code '
9+ import { CodeError } from '@libp2p/interfaces/errors '
1010import { RateLimiterMemory } from 'rate-limiter-flexible'
1111import type { Sink } from 'it-stream-types'
1212import type { StreamMuxer , StreamMuxerInit } from '@libp2p/interface-stream-muxer'
@@ -157,7 +157,7 @@ export class MplexStreamMuxer implements StreamMuxer {
157157 log ( 'new %s stream %s' , type , id )
158158
159159 if ( type === 'initiator' && this . _streams . initiators . size === ( this . _init . maxOutboundStreams ?? MAX_STREAMS_OUTBOUND_STREAMS_PER_CONNECTION ) ) {
160- throw errCode ( new Error ( 'Too many outbound streams open' ) , 'ERR_TOO_MANY_OUTBOUND_STREAMS' )
160+ throw new CodeError ( 'Too many outbound streams open' , 'ERR_TOO_MANY_OUTBOUND_STREAMS' )
161161 }
162162
163163 if ( registry . has ( id ) ) {
@@ -303,7 +303,7 @@ export class MplexStreamMuxer implements StreamMuxer {
303303 } )
304304
305305 // Inform the stream consumer they are not fast enough
306- const error = errCode ( new Error ( 'Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers' ) , 'ERR_STREAM_INPUT_BUFFER_FULL' )
306+ const error = new CodeError ( 'Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers' , 'ERR_STREAM_INPUT_BUFFER_FULL' )
307307 stream . abort ( error )
308308
309309 return
0 commit comments