aboutsummaryrefslogtreecommitdiffstats
path: root/catalog/packages/views/common.py
diff options
context:
space:
mode:
authordyh <dengyuanhong@chinamobile.com>2020-02-19 09:57:17 +0800
committerdyh <dengyuanhong@chinamobile.com>2020-02-19 14:15:19 +0800
commitc0fcb2e4cde1cd5338412e5ce83115626d068f7b (patch)
tree4d754d07d8ee4645e9872cd8b04b4462ecc2193d /catalog/packages/views/common.py
parentb7d87af11036d724710a50116fd3edabe25afd5b (diff)
return 404 instead of 500 if subscription does not exist
Change-Id: I88bd100439ad37e7c14ae74e8f93bd9569875a9c Issue-ID: MODELING-313 Signed-off-by: dyh <dengyuanhong@chinamobile.com>
Diffstat (limited to 'catalog/packages/views/common.py')
-rw-r--r--catalog/packages/views/common.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/catalog/packages/views/common.py b/catalog/packages/views/common.py
index c074faf..12840a5 100644
--- a/catalog/packages/views/common.py
+++ b/catalog/packages/views/common.py
@@ -18,7 +18,7 @@ import logging
from rest_framework import status
from rest_framework.response import Response
-from catalog.pub.exceptions import CatalogException
+from catalog.pub.exceptions import CatalogException, SubscriptionDoesNotExistsException
from catalog.pub.exceptions import BadRequestException
from catalog.pub.exceptions import NsdmBadRequestException
from catalog.pub.exceptions import PackageNotFoundException
@@ -108,6 +108,12 @@ def view_safe_call_with_log(logger):
detail=e.args[0],
status=status.HTTP_400_BAD_REQUEST
)
+ except SubscriptionDoesNotExistsException as e:
+ logger.error(e.args[0])
+ return make_error_resp(
+ detail=e.args[0],
+ status=status.HTTP_404_NOT_FOUND
+ )
except VnfPkgSubscriptionException as e:
logger.error(e.args[0])
return make_error_resp(
@@ -127,5 +133,7 @@ def view_safe_call_with_log(logger):
detail='Unexpected exception',
status=status.HTTP_500_INTERNAL_SERVER_ERROR
)
+
return wrapper
+
return view_safe_call