mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-06-28 07:11:33 +00:00
Update error handling when dialing libp2p connecion (#51)
This commit is contained in:
@ -54,15 +54,6 @@ export interface FluenceConnectionOptions {
|
||||
dialTimeout?: number;
|
||||
}
|
||||
|
||||
export class VersionIncompatibleError extends Error {
|
||||
__proto__: Error;
|
||||
constructor() {
|
||||
const trueProto = new.target.prototype;
|
||||
super('Current version of JS SDK is incompatible with the connected Fluence node. Please update JS SDK');
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
|
||||
export class FluenceConnection {
|
||||
private readonly selfPeerId: PeerId;
|
||||
private node: Peer;
|
||||
@ -128,8 +119,11 @@ export class FluenceConnection {
|
||||
try {
|
||||
await this.node.dial(this.address);
|
||||
} catch (e) {
|
||||
if (e.name === 'AggregateError' && e._errors[0].code === 'ERR_ENCRYPTION_FAILED') {
|
||||
throw new VersionIncompatibleError();
|
||||
if (e.name === 'AggregateError' && e._errors.length === 1) {
|
||||
const error = e._errors[0];
|
||||
throw `Error dialing node ${this.address}:\n${error.code}\n${error.message}`;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user