Skip to content

Commit c01c647

Browse files
authored
Update error handling when dialing libp2p connecion (#51)
1 parent b5bdc5d commit c01c647

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/internal/FluenceConnection.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@ export interface FluenceConnectionOptions {
5454
dialTimeout?: number;
5555
}
5656

57-
export class VersionIncompatibleError extends Error {
58-
__proto__: Error;
59-
constructor() {
60-
const trueProto = new.target.prototype;
61-
super('Current version of JS SDK is incompatible with the connected Fluence node. Please update JS SDK');
62-
this.__proto__ = trueProto;
63-
}
64-
}
65-
6657
export class FluenceConnection {
6758
private readonly selfPeerId: PeerId;
6859
private node: Peer;
@@ -128,8 +119,11 @@ export class FluenceConnection {
128119
try {
129120
await this.node.dial(this.address);
130121
} catch (e) {
131-
if (e.name === 'AggregateError' && e._errors[0].code === 'ERR_ENCRYPTION_FAILED') {
132-
throw new VersionIncompatibleError();
122+
if (e.name === 'AggregateError' && e._errors.length === 1) {
123+
const error = e._errors[0];
124+
throw `Error dialing node ${this.address}:\n${error.code}\n${error.message}`;
125+
} else {
126+
throw e;
133127
}
134128
}
135129

0 commit comments

Comments
 (0)