fix: add type checks for caught errors
This commit is contained in:
parent
aeb1be748e
commit
071cfd7484
@ -8,4 +8,5 @@
|
||||
/.eslintrc.js
|
||||
/test/.eslintrc.js
|
||||
/test/dist
|
||||
/test/rollup.config.js
|
||||
/rollup.config.js
|
||||
|
@ -815,7 +815,7 @@ function createRpcClient(
|
||||
callback(new Error(`${res.status} ${res.statusText}: ${text}`));
|
||||
}
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
if (err instanceof Error) callback(err);
|
||||
} finally {
|
||||
agentManager && agentManager.requestEnd();
|
||||
}
|
||||
@ -3260,7 +3260,7 @@ export class Connection {
|
||||
block.signatures[block.signatures.length - 1].toString();
|
||||
}
|
||||
} catch (err) {
|
||||
if (err.message.includes('skipped')) {
|
||||
if (err instanceof Error && err.message.includes('skipped')) {
|
||||
continue;
|
||||
} else {
|
||||
throw err;
|
||||
@ -3282,7 +3282,7 @@ export class Connection {
|
||||
block.signatures[block.signatures.length - 1].toString();
|
||||
}
|
||||
} catch (err) {
|
||||
if (err.message.includes('skipped')) {
|
||||
if (err instanceof Error && err.message.includes('skipped')) {
|
||||
continue;
|
||||
} else {
|
||||
throw err;
|
||||
@ -3732,7 +3732,13 @@ export class Connection {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
sub.subscriptionId = null;
|
||||
}
|
||||
console.error(`${rpcMethod} error for argument`, rpcArgs, err.message);
|
||||
if (err instanceof Error) {
|
||||
console.error(
|
||||
`${rpcMethod} error for argument`,
|
||||
rpcArgs,
|
||||
err.message,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3750,7 +3756,9 @@ export class Connection {
|
||||
try {
|
||||
await this._rpcWebSocket.call(rpcMethod, [unsubscribeId]);
|
||||
} catch (err) {
|
||||
console.error(`${rpcMethod} error:`, err.message);
|
||||
if (err instanceof Error) {
|
||||
console.error(`${rpcMethod} error:`, err.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {Client as LiveClient} from 'rpc-websockets';
|
||||
import {expect} from 'chai';
|
||||
import sinon from 'sinon';
|
||||
import {createSandbox} from 'sinon';
|
||||
|
||||
import {Connection} from '../../src';
|
||||
|
||||
@ -17,7 +17,7 @@ type RpcResponse = {
|
||||
};
|
||||
|
||||
const mockRpcSocket: Array<[RpcRequest, RpcResponse]> = [];
|
||||
const sandbox = sinon.createSandbox();
|
||||
const sandbox = createSandbox();
|
||||
|
||||
export const mockRpcMessage = ({
|
||||
method,
|
||||
|
Loading…
x
Reference in New Issue
Block a user