From 6d558510aa4c71ed89e9c2b9f67aed2fc19573bb Mon Sep 17 00:00:00 2001 From: Kristjan Pihus Date: Thu, 25 Apr 2019 14:46:00 +0300 Subject: [PATCH] Added import for Price class and error handler to price and transaction streams --- src/context.js | 8 ++++++-- src/pricing.js | 7 +++++-- src/transaction.js | 6 ++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/context.js b/src/context.js index f9868f2..4a0e25a 100644 --- a/src/context.js +++ b/src/context.js @@ -100,7 +100,7 @@ class Context { this.headers['Authorization'] = "Bearer " + this.token; } - request(method, path, body, streamChunkHandler, responseHandler) { + request(method, path, body, streamChunkHandler, responseHandler, errorHandler) { let headers = JSON.parse(JSON.stringify(this.headers)); let postData = ""; @@ -164,7 +164,11 @@ class Context { { req.write(postData); } - + if(errorHandler){ + req.on('error', (error) => { + errorHandler(error); + }) + } req.end(); } } diff --git a/src/pricing.js b/src/pricing.js index bb45af9..2bef5f7 100644 --- a/src/pricing.js +++ b/src/pricing.js @@ -7,6 +7,7 @@ var Property = require('./base').Property; var Field = require('./base').Field; var pricing_common = require('./pricing_common'); +var Price = pricing_common.Price; var order = require('./order'); var instrument = require('./instrument'); @@ -567,7 +568,8 @@ class EntitySpec { accountID, queryParams, streamChunkHandler, - responseHandler + responseHandler, + errorHandler ) { if (!responseHandler) @@ -665,7 +667,8 @@ class EntitySpec { path, body, generateStreamParser(streamChunkHandler), - handleResponse + handleResponse, + errorHandler ); } diff --git a/src/transaction.js b/src/transaction.js index d39f1e4..9ed6e15 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -8099,7 +8099,8 @@ class EntitySpec { stream( accountID, streamChunkHandler, - responseHandler + responseHandler, + errorHandler ) { if (!responseHandler) @@ -8189,7 +8190,8 @@ class EntitySpec { path, body, generateStreamParser(streamChunkHandler), - handleResponse + handleResponse, + errorHandler ); }