Skip to content

Commit

Permalink
virwox, therock, yobit, yunbi error handling unified
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Aug 2, 2017
1 parent 2e45475 commit 1e20e3d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
29 changes: 21 additions & 8 deletions ccxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -11861,7 +11861,7 @@ var therock = {
}, params));
},

request (path, type = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
async request (path, type = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
let url = this.urls['api'] + '/' + this.version + '/' + this.implodeParams (path, params);
let query = this.omit (params, this.extractParams (path));
if (type == 'private') {
Expand All @@ -11877,7 +11877,10 @@ var therock = {
headers['Content-Type'] = 'application/json';
}
}
return this.fetch (url, method, headers, body);
let response = await this.fetch (url, method, headers, body);
if ('errors' in response)
throw new MarketError (this.id + ' ' + this.json (response));
return response;
},
}

Expand Down Expand Up @@ -12323,7 +12326,7 @@ var virwox = {
}, params));
},

request (path, type = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
async request (path, type = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
let url = this.urls['api'][type];
let auth = {};
if (type == 'private') {
Expand All @@ -12345,7 +12348,11 @@ var virwox = {
'id': nonce,
});
}
return this.fetch (url, method, headers, body);
let response = await this.fetch (url, method, headers, body);
if ('error' in response)
if (response['error'])
throw new MarketError (this.id + ' ' + this.json (response));
return response;
},
}

Expand Down Expand Up @@ -12768,7 +12775,7 @@ var yobit = {
}, params));
},

request (path, type = 'api', method = 'GET', params = {}, headers = undefined, body = undefined) {
async request (path, type = 'api', method = 'GET', params = {}, headers = undefined, body = undefined) {
let url = this.urls['api'] + '/' + type;
if (type == 'api') {
url += '/' + this.version + '/' + this.implodeParams (path, params);
Expand All @@ -12785,7 +12792,10 @@ var yobit = {
'sign': this.hmac (this.encode (body), this.encode (this.secret), 'sha512'),
};
}
return this.fetch (url, method, headers, body);
let response = await this.fetch (url, method, headers, body);
if ('error' in response)
throw new MarketError (this.id + ' ' + this.json (response));
return response;
},
}

Expand Down Expand Up @@ -12964,7 +12974,7 @@ var yunbi = {
return this.privatePostOrderDelete ({ 'id': id });
},

request (path, type = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
async request (path, type = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
let request = '/api/' + this.version + '/' + this.implodeParams (path, params) + '.json';
let query = this.omit (params, this.extractParams (path));
let url = this.urls['api'] + request;
Expand All @@ -12990,7 +13000,10 @@ var yunbi = {
};
}
}
return this.fetch (url, method, headers, body);
let response = await this.fetch (url, method, headers, body);
if ('error' in response)
throw new MarketError (this.id + ' ' + this.json (response));
return
},
}

Expand Down
2 changes: 1 addition & 1 deletion keys.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"quadrigacx": { "apiKey": "QwxLbyUbzO", "secret": "ed88da90963dbdd8f609c26b257f681c", "uid": "395037" },
"quoine": { "apiKey": "85626", "secret": "i7yxQvToODd6h9BqMyGODUHBiZRL13Fn1nfJRifgfnha43HuHop9NuBGZOfj7ydf04hp6PMRRiPyOB5Hmm1WoA==" },
"southxchange": { "apiKey": "OWSEIrJrtGtqDhBXoMIjpiyvQnVfoj", "secret": "xKyYfjiSMdMvQNXDTwEjTsLiHLedsAUkCqNjwEiWvvfLvarkws" },
"therock": { "apiKey": "a521b8c93466ccf5fdcd2dcad1bb1b287e41ec2b", "secret": "4b9c88b0a6f0688464542f9a74548edf85375134" },
"therock": { "apiKey": "1a521b8c93466ccf5fdcd2dcad1bb1b287e41ec2b", "secret": "4b9c88b0a6f0688464542f9a74548edf85375134" },
"vaultoro": { "apiKey": "7omZ3XSd74T87JSCsTyKTtD5ppRBarQL", "secret": "eWIzZENZbkkzV0pCRU9LMUprWDBhN3EwV1VpOEdCWnY=" },
"virwox": { "apiKey": "1ea680450b32585f743c50c051bf8e4e", "login": "IgorKroitor", "password": "HfveVskfVfvf260" },
"xbtce": { "apiKey": "dK2jBXMTppAM57ZJ", "secret": "qGNTrzs3d956DZKSRnPPJ5nrQJCwetAnh7cR6Mkj5E4eRQyMKwKqH7ywsxcR78WT", "uid": "68ef0552-3c37-4896-ba56-76173d9cd573" },
Expand Down
8 changes: 7 additions & 1 deletion run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ const keys = {

'--js': false, // run JavaScript tests only
'--php': false, // run PHP tests only
'--python': false, // run Python tests only
'--python': false, // run (all?) Python tests only
// reserved for future use
// '--python2': false, // run Python 2 tests only
// '--python3': false, // run Python 3 tests only
'--es6': false, // run JS tests against ccxt.js instead of ccxt.es5.js (no need to `npm run build` before)
}

Expand Down Expand Up @@ -112,6 +115,9 @@ const testMarket = async (market) => {

{ language: 'JavaScript', key: '--js', exec: ['node', 'test.js', ...args, ...keys['--es6'] ? ['--es6'] : []] },
{ language: 'Python', key: '--python', exec: ['python', 'test.py', ...args] },
// added for future use (nearest future, I hope)
// { language: 'Python 2', key: '--python2', exec: ['python2', 'test.py', ...args] },
// { language: 'Python 3', key: '--python3', exec: ['python3', 'test.py', ...args] },
{ language: 'PHP', key: '--php', exec: ['php', '-f', 'test.php', ...args] }
]
, selectedTests = allTests.filter (t => keys[t.key])
Expand Down

0 comments on commit 1e20e3d

Please sign in to comment.