1 # Copyright (c) 2018 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """Implementation of exceptions used in the wrk traffic generator.
18 from robot.api import logger
21 class WrkError(Exception):
22 """Exception(s) raised by the wrk traffic generator.
24 When raising this exception, put this information to the message in this
26 - short description of the encountered problem (parameter msg),
27 - relevant messages if there are any collected, e.g., from caught
28 exception (optional parameter details),
29 - relevant data if there are any collected (optional parameter details).
32 def __init__(self, msg, details=''):
33 """Sets the exception message and the level.
35 :param msg: Short description of the encountered problem.
36 :param details: Relevant messages if there are any collected, e.g.:
37 from caught exception (optional parameter details), or relevant data if
38 there are any collected (optional parameter details).
43 super(WrkError, self).__init__()
45 self._details = details
47 logger.error(self._msg)
49 logger.error(self._details)
52 return repr(self._msg)