From 7aa2b2f1c088da52540d55877edd7921cc55ed54 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 5 Aug 2020 17:52:51 +0530 Subject: error handling --- talerbank/app/middleware.py | 5 +++-- talerbank/app/views.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/talerbank/app/middleware.py b/talerbank/app/middleware.py index 093ff20..eeb6a67 100644 --- a/talerbank/app/middleware.py +++ b/talerbank/app/middleware.py @@ -95,17 +95,18 @@ class ExceptionMiddleware: if so. Otherwise, it lets the native handler operate. """ LOGGER.error(f"Error: {exception}, while serving {request.get_full_path()}") + LOGGER.error(f"Stack trace: {traceback.format_exc()}") if hasattr(exception, "taler_error_code"): render_to = self.render.get(request.path) if not render_to: return JsonResponse( - {"ec": exception.taler_error_code, "error": exception.hint}, + {"code": exception.taler_error_code, "error": exception.hint}, status=exception.http_status_code, ) set_profile_hint(request, failure=True, success=False, hint=exception.hint) return redirect(render_to) else: - return JsonResponse(dict(hint="unexpected exception", exception=str(exception)), status=500) + return JsonResponse(dict(code=5300, hint="unexpected exception", exception=str(exception)), status=500) diff --git a/talerbank/app/views.py b/talerbank/app/views.py index 0b25c3d..b450fc7 100644 --- a/talerbank/app/views.py +++ b/talerbank/app/views.py @@ -1029,7 +1029,7 @@ def api_withdraw_operation(request, withdraw_id): exchange_user = User.objects.get(username=exchange_account_name) except User.DoesNotExist: return JsonResponse( - dict(error="bank account in payto URI unknown"), status=400 + dict(code=5110, hint="bank account in payto URI unknown"), status=400 ) exchange_account = exchange_user.bankaccount selected_reserve_pub = data.get("reserve_pub") @@ -1052,7 +1052,7 @@ def api_withdraw_operation(request, withdraw_id): # Confirmation already happened, we still need to transfer funds! wire_transfer( op.amount, - user_account, + op.withdraw_account, op.selected_exchange_account, op.selected_reserve_pub, ) -- cgit v1.2.3