From 25bd0ca72302fa74d409050546686a6afec698fe Mon Sep 17 00:00:00 2001 From: Daniel Kowalczyk Date: Wed, 27 Sep 2017 15:04:39 +0200 Subject: [PATCH] Raise an exception instead of returning string error message --- bitfinex/client.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bitfinex/client.py b/bitfinex/client.py index 5018cf0..105171c 100644 --- a/bitfinex/client.py +++ b/bitfinex/client.py @@ -21,6 +21,9 @@ TIMEOUT = 5.0 +class BitfinexException(Exception): + pass + class TradeClient: """ @@ -84,7 +87,7 @@ def place_order(self, amount, price, side, ord_type, symbol='btcusd', exchange=' try: json_resp['order_id'] except: - return json_resp['message'] + raise BitfinexException(json_resp['message']) return json_resp @@ -107,7 +110,7 @@ def delete_order(self, order_id): try: json_resp['avg_execution_price'] except: - return json_resp['message'] + raise BitfinexException(json_resp['message']) return json_resp @@ -146,7 +149,7 @@ def status_order(self, order_id): try: json_resp['avg_execution_price'] except: - return json_resp['message'] + raise BitfinexException(json_resp['message']) return json_resp