def error_msg_from_exception(e):
 msg = u''
 if hasattr(e, u'message'):
  if (type(e.message) is dict):
   msg = e.message.get(u'message')
  elif e.message:
   msg = u'{}'.format(e.message)
 return (msg or u'{}'.format(e))

def error_msg_from_exception ( e ) : msg = u'' if hasattr ( e , u'message' ) : if ( type ( e . message ) is dict ) : msg = e . message . get ( u'message' ) elif e . message : msg = u'{}' . format ( e . message ) return ( msg or u'{}' . format ( e ) )
translate exception into error message database have different ways to handle exception .