@@ -4,7 +4,7 @@ import type { Connection } from '@libp2p/interface-connection'
4
4
import type { PeerId } from '@libp2p/interface-peer-id'
5
5
import type { ConnectionManager , ConnectionManagerEvents } from '@libp2p/interface-connection-manager'
6
6
import { connectionPair } from './connection.js'
7
- import errCode from 'err-code '
7
+ import { CodeError } from '@libp2p/interfaces/errors '
8
8
import type { Registrar } from '@libp2p/interface-registrar'
9
9
import type { PubSub } from '@libp2p/interface-pubsub'
10
10
import { isMultiaddr , Multiaddr } from '@multiformats/multiaddr'
@@ -30,7 +30,7 @@ class MockNetwork {
30
30
}
31
31
}
32
32
33
- throw errCode ( new Error ( 'Peer not found' ) , 'ERR_PEER_NOT_FOUND' )
33
+ throw new CodeError ( 'Peer not found' , 'ERR_PEER_NOT_FOUND' )
34
34
}
35
35
36
36
reset ( ) : void {
@@ -78,7 +78,7 @@ class MockConnectionManager extends EventEmitter<ConnectionManagerEvents> implem
78
78
79
79
async openConnection ( peerId : PeerId | Multiaddr ) : Promise < Connection > {
80
80
if ( this . components == null ) {
81
- throw errCode ( new Error ( 'Not initialized' ) , 'ERR_NOT_INITIALIZED' )
81
+ throw new CodeError ( 'Not initialized' , 'ERR_NOT_INITIALIZED' )
82
82
}
83
83
84
84
if ( isMultiaddr ( peerId ) ) {
@@ -124,7 +124,7 @@ class MockConnectionManager extends EventEmitter<ConnectionManagerEvents> implem
124
124
125
125
async closeConnections ( peerId : PeerId ) : Promise < void > {
126
126
if ( this . components == null ) {
127
- throw errCode ( new Error ( 'Not initialized' ) , 'ERR_NOT_INITIALIZED' )
127
+ throw new CodeError ( 'Not initialized' , 'ERR_NOT_INITIALIZED' )
128
128
}
129
129
130
130
const connections = this . getConnections ( peerId )
0 commit comments