diff --git a/package.json b/package.json index fd29317..3ea6ef2 100644 --- a/package.json +++ b/package.json @@ -143,10 +143,9 @@ "docs": "aegir docs" }, "dependencies": { - "@libp2p/interfaces": "^3.0.2", + "@libp2p/interfaces": "^3.2.0", "@libp2p/logger": "^2.0.0", "abortable-iterator": "^4.0.2", - "err-code": "^3.0.1", "it-first": "^2.0.0", "it-handshake": "^4.1.2", "it-length-prefixed": "^8.0.3", diff --git a/src/multistream.ts b/src/multistream.ts index 7d33914..cd2b932 100644 --- a/src/multistream.ts +++ b/src/multistream.ts @@ -2,7 +2,7 @@ import { Uint8ArrayList } from 'uint8arraylist' import * as lp from 'it-length-prefixed' import { pipe } from 'it-pipe' -import errCode from 'err-code' +import { CodeError } from '@libp2p/interfaces/errors' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import first from 'it-first' import { abortableSource } from 'abortable-iterator' @@ -82,12 +82,12 @@ export async function read (reader: Reader, options?: AbortOptions): Promise, protocols: string | string[], } rest() - throw errCode(new Error('protocol selection failed'), 'ERR_UNSUPPORTED_PROTOCOL') + throw new CodeError('protocol selection failed', 'ERR_UNSUPPORTED_PROTOCOL') } /** @@ -147,7 +147,7 @@ export function lazySelect (stream: Duplex, protocol: string): ProtocolStre response = await multistream.readString(byteReader) } if (response !== protocol) { - throw errCode(new Error('protocol selection failed'), 'ERR_UNSUPPORTED_PROTOCOL') + throw new CodeError('protocol selection failed', 'ERR_UNSUPPORTED_PROTOCOL') } for await (const chunk of byteReader) { yield * chunk