exception.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2015 Airbus
00004 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00005 #
00006 # Licensed under the Apache License, Version 2.0 (the "License");
00007 # you may not use this file except in compliance with the License.
00008 # You may obtain a copy of the License at
00009 #
00010 #   http://www.apache.org/licenses/LICENSE-2.0
00011 #
00012 # Unless required by applicable law or agreed to in writing, software
00013 # distributed under the License is distributed on an "AS IS" BASIS,
00014 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 # See the License for the specific language governing permissions and
00016 # limitations under the License.
00017 
00018 import rospy
00019 import inspect
00020 
00021 
00022 def stdmsg(frame_desc=[], msg="Unknow"):
00023     
00024     if str(frame_desc[1]) == "<module>":
00025         frame_desc[1] = "__main__"
00026     
00027     msg = '[MSG]:%s [FILE]:%s [IN]:%s() [LINE]:%s'%(msg,
00028                                                    str(frame_desc[0]),
00029                                                    str(frame_desc[1]),
00030                                                    str(frame_desc[2]))
00031     return msg
00032 
00033 ## @package: exception
00034 ##
00035 ## @version 1.0
00036 ## @author  Matignon Martin
00037 ## @date    Last modified 30/04/2014
00038 
00039 ## @class CobotGuiException
00040 ## @brief Object for create an exception.
00041 class CobotGuiException(Exception):
00042     
00043     def __init__(self, msg):
00044         self.msg = msg
00045         
00046         callerframerecord = inspect.stack()[1]
00047         frame = callerframerecord[0]
00048         info = inspect.getframeinfo(frame)
00049         filepyname = info.filename.split('/')
00050         
00051         rospy.logerr(stdmsg([filepyname[-1],info.function,info.lineno],msg))
00052         
00053     def __str__(self):
00054         return repr(self.msg)
00055     
00056 if __name__ == "__main__":
00057     
00058     rospy.init_node('utt_airbus_cobot_gui_exception')
00059     
00060     try:
00061         x = 5/0
00062     except Exception as e:
00063         raise CobotGuiException(e)
00064     


airbus_cobot_gui
Author(s): Martin Matignon
autogenerated on Thu Jun 6 2019 17:59:19