summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_exceptions.py
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-02-11 12:53:07 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2016-02-11 12:53:07 +0200
commit9adfbada8a429dcdd7bf95d9b52d28bb3448e1d4 (patch)
treed8473c54c1520103a5ae45200868ffb949d11592 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_exceptions.py
parent4b3092339d578f2c08de2fa1a55de5dea5ecf053 (diff)
validate_type for easier type checks, hltapi move to trex_stl_lib
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_exceptions.py')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_exceptions.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_exceptions.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_exceptions.py
index 45acc72e..e84b032b 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_exceptions.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_exceptions.py
@@ -10,6 +10,8 @@ class STLError(Exception):
def __str__ (self):
exc_type, exc_obj, exc_tb = sys.exc_info()
+ if not exc_tb:
+ return self.msg
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
@@ -35,7 +37,7 @@ class STLPortStateError(STLError):
self.msg = "Operation '{0}' on port(s) '{1}' is not valid while port(s) '{2}'".format(op, port, state)
-# raised when argument is not valid for operation
+# raised when argument value is not valid for operation
class STLArgumentError(STLError):
def __init__ (self, name, got, valid_values = None, extended = None):
self.msg = "Argument: '{0}' invalid value: '{1}'".format(name, got)
@@ -45,10 +47,14 @@ class STLArgumentError(STLError):
if extended:
self.msg += "\n{0}".format(extended)
+# raised when argument type is not valid for operation
+class STLTypeError(STLError):
+ def __init__ (self, arg_name, arg_type, valid_types):
+ self.msg = "Argument: '%s' invalid type: %s, expecting type(s): %s." % (arg_name, arg_type, valid_types)
+
# raised when timeout occurs
class STLTimeoutError(STLError):
def __init__ (self, timeout):
self.msg = "Timeout: operation took more than '{0}' seconds".format(timeout)
-