Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/internal/FluenceConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

Expand Down