From d9675ad6d3ca5e1c124c91d182cfbec9c912fb15 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 15 Jan 2019 11:48:04 +0100 Subject: Refactor logAsyncErrors to follow our conventions --- .../sol-tracing-utils/src/trace_collection_subprovider.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'packages') diff --git a/packages/sol-tracing-utils/src/trace_collection_subprovider.ts b/packages/sol-tracing-utils/src/trace_collection_subprovider.ts index e3f5561aa..d79c5ca22 100644 --- a/packages/sol-tracing-utils/src/trace_collection_subprovider.ts +++ b/packages/sol-tracing-utils/src/trace_collection_subprovider.ts @@ -1,4 +1,5 @@ import { BlockchainLifecycle } from '@0x/dev-utils'; +import { logUtils } from '@0x/utils'; import { Callback, ErrorCallback, NextCallback, Subprovider } from '@0x/subproviders'; import { CallDataRPC, marshaller, Web3Wrapper } from '@0x/web3-wrapper'; import { JSONRPCRequestPayload, Provider, TxData } from 'ethereum-types'; @@ -25,14 +26,14 @@ type AsyncFunc = (...args: any[]) => Promise; // This wrapper outputs errors to console even if the promise gets ignored // we need this because web3-provider-engine does not handle promises in // the after function of next(after). -function logErrors(fn: AsyncFunc): AsyncFunc { +function logAsyncErrors(fn: AsyncFunc): AsyncFunc { async function wrappedAsync(...args: any[]): Promise { try { await fn(...args); - } catch (e) { + } catch (err) { // tslint:disable-next-line no-console - console.error(e); - throw e; + logUtils.error(err); + throw err; } } return wrappedAsync; @@ -92,7 +93,7 @@ export abstract class TraceCollectionSubprovider extends Subprovider { next(); } else { const txData = payload.params[0]; - next(logErrors(this._onTransactionSentAsync.bind(this, txData))); + next(logAsyncErrors(this._onTransactionSentAsync.bind(this, txData))); } return; @@ -101,7 +102,7 @@ export abstract class TraceCollectionSubprovider extends Subprovider { next(); } else { const callData = payload.params[0]; - next(logErrors(this._onCallOrGasEstimateExecutedAsync.bind(this, callData))); + next(logAsyncErrors(this._onCallOrGasEstimateExecutedAsync.bind(this, callData))); } return; @@ -110,7 +111,7 @@ export abstract class TraceCollectionSubprovider extends Subprovider { next(); } else { const estimateGasData = payload.params[0]; - next(logErrors(this._onCallOrGasEstimateExecutedAsync.bind(this, estimateGasData))); + next(logAsyncErrors(this._onCallOrGasEstimateExecutedAsync.bind(this, estimateGasData))); } return; -- cgit v1.2.3