aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/utils/exceptions.py
diff options
context:
space:
mode:
authorSylvain Desbureaux <sylvain.desbureaux@orange.com>2020-12-01 17:49:31 +0100
committerSylvain Desbureaux <sylvain.desbureaux@orange.com>2020-12-01 17:51:56 +0100
commit9c71e24adaaedd07d7e2e65922c5a3cee27318c9 (patch)
treea47f904d81a6afbadd8b451563d34fcd974e6bcd /src/onaptests/utils/exceptions.py
parenta6fe8be6c1d1eb9e7293ed1c3bb63a76646fe22c (diff)
Better exception handling
Instead of catching all exceptions that can occurs and miss one, let's create a "parent" exception class for OnapTest and catch only this one. In order to know what's the error, we also create a class attribute (`error_message`) that gives us the reason for exception. Issue-ID: INT-1796 Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com> Change-Id: I798d8c6270c466b1d9be6511f52fd9441401c9c8
Diffstat (limited to 'src/onaptests/utils/exceptions.py')
-rw-r--r--src/onaptests/utils/exceptions.py52
1 files changed, 32 insertions, 20 deletions
diff --git a/src/onaptests/utils/exceptions.py b/src/onaptests/utils/exceptions.py
index daadc32..8b359c3 100644
--- a/src/onaptests/utils/exceptions.py
+++ b/src/onaptests/utils/exceptions.py
@@ -1,6 +1,4 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2018 Orange and others.
+# Copyright (c) 2018-2020 Orange and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
@@ -10,48 +8,62 @@
__author__ = ("Morgan Richomme <morgan.richomme@orange.com>")
+class OnapTestException(Exception):
+ """Parent Class for all Onap Test Exceptions."""
+ error_message='Generic OnapTest exception'
-class TestConfigurationException(Exception):
+class TestConfigurationException(OnapTestException):
"""Raise when configutation of the use cases is not complete or buggy."""
+ error_message='Configuration error'
-
-class ServiceDistributionException(Exception):
+class ServiceDistributionException(OnapTestException):
"""Service not properly distributed."""
+ error_message='Service not well distributed'
-class ServiceInstantiateException(Exception):
- """Service cannot be instantiate."""
+class ServiceInstantiateException(OnapTestException):
+ """Service cannot be instantiated."""
+ error_message='Service instantiation error'
-class ServiceCleanupException(Exception):
+class ServiceCleanupException(OnapTestException):
"""Service cannot be cleaned."""
+ error_message='Service not well cleaned up'
-class VnfInstantiateException(Exception):
- """VNF cannot be instantiate."""
+class VnfInstantiateException(OnapTestException):
+ """VNF cannot be instantiated."""
+ error_message='VNF instantiation error'
-class VnfCleanupException(Exception):
+class VnfCleanupException(OnapTestException):
"""VNF cannot be cleaned."""
+ error_message="VNF can't be cleaned"
-class VfModuleInstantiateException(Exception):
- """VF Module cannot be instantiate."""
+class VfModuleInstantiateException(OnapTestException):
+ """VF Module cannot be instantiated."""
+ error_message='VF Module instantiation error'
-class VfModuleCleanupException(Exception):
- """VF Module cannot be instantiate."""
+class VfModuleCleanupException(OnapTestException):
+ """VF Module cannot be cleaned."""
+ error_message="VF Module can't be cleaned"
-class NetworkInstantiateException(Exception):
+class NetworkInstantiateException(OnapTestException):
"""Network cannot be instantiate."""
+ error_message='Network instantiation error'
-class NetworkCleanupException(Exception):
+class NetworkCleanupException(OnapTestException):
"""Network cannot be cleaned."""
+ error_message="Network can't be cleaned"
-class ProfileInformationException(Exception):
+class ProfileInformationException(OnapTestException):
"""Missing k8s profile information."""
+ error_message='"Missing k8s profile information'
-class ProfileCleanupException(Exception):
+class ProfileCleanupException(OnapTestException):
"""K8s profile cannot be cleaned."""
+ error_message="Profile can't be cleaned"