rename exception handlers

This commit is contained in:
Matthias 2019-05-18 13:39:12 +02:00
parent e6ae890def
commit 2cf07e2185

View File

@ -41,7 +41,7 @@ class ApiServer(RPC):
This class starts a none blocking thread the api server runs within This class starts a none blocking thread the api server runs within
""" """
def safe_rpc(func): def rpc_catch_errors(func):
def func_wrapper(self, *args, **kwargs): def func_wrapper(self, *args, **kwargs):
@ -169,6 +169,7 @@ class ApiServer(RPC):
'code': 404 'code': 404
}), 404 }), 404
@rpc_catch_errors
def _start(self): def _start(self):
""" """
Handler for /start. Handler for /start.
@ -177,6 +178,7 @@ class ApiServer(RPC):
msg = self._rpc_start() msg = self._rpc_start()
return self.rest_dump(msg) return self.rest_dump(msg)
@rpc_catch_errors
def _stop(self): def _stop(self):
""" """
Handler for /stop. Handler for /stop.
@ -185,6 +187,7 @@ class ApiServer(RPC):
msg = self._rpc_stop() msg = self._rpc_stop()
return self.rest_dump(msg) return self.rest_dump(msg)
@rpc_catch_errors
def _stopbuy(self): def _stopbuy(self):
""" """
Handler for /stopbuy. Handler for /stopbuy.
@ -193,12 +196,14 @@ class ApiServer(RPC):
msg = self._rpc_stopbuy() msg = self._rpc_stopbuy()
return self.rest_dump(msg) return self.rest_dump(msg)
@rpc_catch_errors
def _version(self): def _version(self):
""" """
Prints the bot's version Prints the bot's version
""" """
return self.rest_dump({"version": __version__}) return self.rest_dump({"version": __version__})
@rpc_catch_errors
def _reload_conf(self): def _reload_conf(self):
""" """
Handler for /reload_conf. Handler for /reload_conf.
@ -207,7 +212,7 @@ class ApiServer(RPC):
msg = self._rpc_reload_conf() msg = self._rpc_reload_conf()
return self.rest_dump(msg) return self.rest_dump(msg)
@safe_rpc @rpc_catch_errors
def _count(self): def _count(self):
""" """
Handler for /count. Handler for /count.
@ -216,7 +221,7 @@ class ApiServer(RPC):
msg = self._rpc_count() msg = self._rpc_count()
return self.rest_dump(msg) return self.rest_dump(msg)
@safe_rpc @rpc_catch_errors
def _daily(self): def _daily(self):
""" """
Returns the last X days trading stats summary. Returns the last X days trading stats summary.
@ -233,7 +238,7 @@ class ApiServer(RPC):
return self.rest_dump(stats) return self.rest_dump(stats)
@safe_rpc @rpc_catch_errors
def _edge(self): def _edge(self):
""" """
Returns information related to Edge. Returns information related to Edge.
@ -243,7 +248,7 @@ class ApiServer(RPC):
return self.rest_dump(stats) return self.rest_dump(stats)
@safe_rpc @rpc_catch_errors
def _profit(self): def _profit(self):
""" """
Handler for /profit. Handler for /profit.
@ -259,7 +264,7 @@ class ApiServer(RPC):
return self.rest_dump(stats) return self.rest_dump(stats)
@safe_rpc @rpc_catch_errors
def _performance(self): def _performance(self):
""" """
Handler for /performance. Handler for /performance.
@ -273,7 +278,7 @@ class ApiServer(RPC):
return self.rest_dump(stats) return self.rest_dump(stats)
@safe_rpc @rpc_catch_errors
def _status(self): def _status(self):
""" """
Handler for /status. Handler for /status.
@ -283,7 +288,7 @@ class ApiServer(RPC):
results = self._rpc_trade_status() results = self._rpc_trade_status()
return self.rest_dump(results) return self.rest_dump(results)
@safe_rpc @rpc_catch_errors
def _balance(self): def _balance(self):
""" """
Handler for /balance. Handler for /balance.
@ -293,7 +298,7 @@ class ApiServer(RPC):
results = self._rpc_balance(self._config.get('fiat_display_currency', '')) results = self._rpc_balance(self._config.get('fiat_display_currency', ''))
return self.rest_dump(results) return self.rest_dump(results)
@safe_rpc @rpc_catch_errors
def _whitelist(self): def _whitelist(self):
""" """
Handler for /whitelist. Handler for /whitelist.
@ -301,7 +306,7 @@ class ApiServer(RPC):
results = self._rpc_whitelist() results = self._rpc_whitelist()
return self.rest_dump(results) return self.rest_dump(results)
@safe_rpc @rpc_catch_errors
def _blacklist(self): def _blacklist(self):
""" """
Handler for /blacklist. Handler for /blacklist.
@ -310,7 +315,7 @@ class ApiServer(RPC):
results = self._rpc_blacklist(add) results = self._rpc_blacklist(add)
return self.rest_dump(results) return self.rest_dump(results)
@safe_rpc @rpc_catch_errors
def _forcebuy(self): def _forcebuy(self):
""" """
Handler for /forcebuy. Handler for /forcebuy.
@ -323,7 +328,7 @@ class ApiServer(RPC):
else: else:
return self.rest_dump({"status": f"Error buying pair {asset}."}) return self.rest_dump({"status": f"Error buying pair {asset}."})
@safe_rpc @rpc_catch_errors
def _forcesell(self): def _forcesell(self):
""" """
Handler for /forcesell. Handler for /forcesell.