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