Skip to content

Commit ab2ca06

Browse files
committed
Add onError callback to connect function
1 parent 136c66f commit ab2ca06

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/client/LumClient.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,20 @@ export class LumClient {
9595
* Uses HTTP when the URL schema is http or https, uses WebSockets otherwise
9696
*
9797
* @param endpoint Blockchain node RPC url
98+
* @param onError Callback for errors
9899
*/
99-
static connect = async (endpoint: string): Promise<LumClient> => {
100-
const tmClient = await Tendermint34Client.connect(endpoint);
101-
return new LumClient(tmClient);
100+
static connect = async (endpoint: string, onError?: (e: unknown) => void): Promise<LumClient> => {
101+
try {
102+
const tmClient = await Tendermint34Client.connect(endpoint);
103+
104+
return new LumClient(tmClient);
105+
} catch (e) {
106+
if (onError) {
107+
onError(e);
108+
}
109+
110+
throw e;
111+
}
102112
};
103113

104114
/**

0 commit comments

Comments
 (0)