diff --git a/src/NWCClient.ts b/src/NWCClient.ts index 44bb051..255c964 100644 --- a/src/NWCClient.ts +++ b/src/NWCClient.ts @@ -181,6 +181,7 @@ export class Nip47PublishError extends Nip47Error {} export class Nip47ResponseDecodingError extends Nip47Error {} export class Nip47ResponseValidationError extends Nip47Error {} export class Nip47UnexpectedResponseError extends Nip47Error {} +export class Nip47NetworkError extends Nip47Error {} export const NWCs: Record = { alby: { @@ -1011,6 +1012,14 @@ export class NWCClient { if (!this.secret) { throw new Error("Missing secret key"); } - await this.relay.connect(); + try { + await this.relay.connect(); + } catch (_ /* error is always undefined */) { + console.error("failed to connect to relay", this.relayUrl); + throw new Nip47NetworkError( + "Failed to connect to " + this.relayUrl, + "OTHER", + ); + } } }