From 8a8d5ceec41726730885286e7b9269bebf39cef4 Mon Sep 17 00:00:00 2001 From: PengfeiLi0218 Date: Mon, 28 Jan 2019 23:59:15 +0800 Subject: [PATCH 1/2] Error handling for KPI Dashboard of API Manager if CanGetConsumers, CanGetAnyUser is not present #65 --- apimanager/metrics/views.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apimanager/metrics/views.py b/apimanager/metrics/views.py index c9ae87e2..d7623a35 100644 --- a/apimanager/metrics/views.py +++ b/apimanager/metrics/views.py @@ -143,6 +143,8 @@ def get_metrics(self, cleaned_data): metrics = self.to_django(metrics['metrics']) except APIError as err: error_once_only(self.request, err) + except KeyError as err: + error_once_only(self.request, err) return metrics def get_context_data(self, **kwargs): From c515a822f5115faa5128016a4a24c1195978bc56 Mon Sep 17 00:00:00 2001 From: PengfeiLi0218 Date: Tue, 29 Jan 2019 00:07:20 +0800 Subject: [PATCH 2/2] Error handling for KPI Dashboard of API Manager if CanGetConsumers, CanGetAnyUser is not present #65 --- apimanager/metrics/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apimanager/metrics/views.py b/apimanager/metrics/views.py index d7623a35..5b07a3aa 100644 --- a/apimanager/metrics/views.py +++ b/apimanager/metrics/views.py @@ -144,7 +144,9 @@ def get_metrics(self, cleaned_data): except APIError as err: error_once_only(self.request, err) except KeyError as err: - error_once_only(self.request, err) + error_once_only(self.request, metrics['message']) + except: + error_once_only(self.request, 'Unknown Error') return metrics def get_context_data(self, **kwargs):