exception.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 ################################################################################
3 #
4 # Copyright Airbus Group SAS 2015
5 # All rigths reserved.
6 #
7 # File Name : exception.py
8 # Authors : Martin Matignon
9 #
10 # If you find any bug or if you have any question please contact
11 # Adolfo Suarez Roos <adolfo.suarez@airbus.com>
12 # Martin Matignon <martin.matignon.external@airbus.com>
13 #
14 #
15 ################################################################################
16 import rospy
17 import inspect
18 
19 
20 def stdmsg(frame_desc=[], msg="Unknow"):
21 
22  if str(frame_desc[1]) == "<module>":
23  frame_desc[1] = "__main__"
24 
25  msg = '[MSG]:%s [FILE]:%s [IN]:%s() [LINE]:%s'%(msg,
26  str(frame_desc[0]),
27  str(frame_desc[1]),
28  str(frame_desc[2]))
29  return msg
30 
31 ## @package: exception
32 ##
33 ## @version 1.0
34 ## @author Matignon Martin
35 ## @date Last modified 30/04/2014
36 
37 ## @class CobotGuiException
38 ## @brief Object for create an exception.
39 class CobotGuiException(Exception):
40 
41  def __init__(self, msg):
42  self.msg = msg
43 
44  callerframerecord = inspect.stack()[1]
45  frame = callerframerecord[0]
46  info = inspect.getframeinfo(frame)
47  filepyname = info.filename.split('/')
48 
49  rospy.logerr(stdmsg([filepyname[-1],info.function,info.lineno],msg))
50 
51  def __str__(self):
52  return repr(self.msg)
53 
54 if __name__ == "__main__":
55 
56  rospy.init_node('utt_airbus_cobot_gui_exception')
57 
58  try:
59  x = 5/0
60  except Exception as e:
61  raise CobotGuiException(e)
62 


airbus_cobot_gui
Author(s):
autogenerated on Thu Dec 17 2015 11:42:05