irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

irods_exception.hpp
Go to the documentation of this file.
1 #ifndef IRODS_EXCEPTION_HPP
2 #define IRODS_EXCEPTION_HPP
3 
4 #include <exception>
5 #include <string>
6 #include <sstream>
7 #include <vector>
8 #include <inttypes.h>
9 #include <boost/format.hpp>
10 
11 #include <irods_stacktrace.hpp>
12 
13 namespace irods {
14 
15  class exception : public std::exception {
16  public:
17  exception(
18  const int64_t _code,
19  const std::string& _message,
20  const std::string& _file_name,
21  const uint32_t _line_number,
22  const std::string& _function_name );
23  exception(
24  const int64_t _code,
25  const boost::format& _message,
26  const std::string& _file_name,
27  const uint32_t _line_number,
28  const std::string& _function_name );
29  exception( const exception& );
30  virtual ~exception() throw();
31 
32  // This is used internally, not in the icommands
33  virtual const char* what() const throw();
34 
35  // This should be used by icommands, instead of what()
36  virtual const char* client_display_what() const throw();
37 
38  // accessors
39  int64_t code() const { return code_; }
40  std::vector< std::string > message_stack() const { return message_stack_; }
41  std::string file_name() const { return file_name_; }
42  uint32_t line_number() const { return line_number_; }
43  std::string function_name() const { return function_name_; }
45 
46  // mutators
47  void add_message( const std::string& _m ) { message_stack_.push_back( _m ); }
48 
49  private:
50  // Assemble the what_ string depending on what kind of what() was called...
51  void assemble_full_display_what() const throw();
52  void assemble_client_display_what() const throw();
53 
54  private:
55  int64_t code_;
56  std::vector< std::string > message_stack_;
57  uint32_t line_number_;
58  std::string function_name_;
59  std::string file_name_;
61  mutable std::string what_;
62 
63  }; // class exception
64 
65 
66 }; // namespace irods
67 
68 #define THROW( _code, _msg ) ( throw irods::exception( _code, _msg, __FILE__, __LINE__, __PRETTY_FUNCTION__ ) )
69 #define RE_THROW( _msg, _excp ) _excp.add_message( _msg ); throw _excp;
70 #define CATCH_EXC_AND_RETURN( throwing_expression ) try { throwing_expression; } catch (const irods::exception& e) { rodsLog( LOG_ERROR, e.code(), "%s encountered an exception on line %d in file %s:\n%s", __PRETTY_FUNCTION__, __LINE__, __FILE__, e.what()); return e.code() }
71 #define CATCH_EXC_AND_LOG( throwing_expression ) try { throwing_expression; } catch (const irods::exception& e) { rodsLog( LOG_ERROR, e.code(), "%s encountered an exception on line %d in file %s:\n%s", __PRETTY_FUNCTION__, __LINE__, __FILE__, e.what()); }
72 
73 #endif // IRODS_EXCEPTION_HPP
irods::exception::exception
exception(const int64_t _code, const std::string &_message, const std::string &_file_name, const uint32_t _line_number, const std::string &_function_name)
Definition: irods_exception.cpp:7
irods::exception::stacktrace_
irods::stacktrace stacktrace_
Definition: irods_exception.hpp:60
irods::exception::line_number
uint32_t line_number() const
Definition: irods_exception.hpp:42
irods::exception::stacktrace
irods::stacktrace stacktrace() const
Definition: irods_exception.hpp:44
irods_stacktrace.hpp
irods::exception::function_name
std::string function_name() const
Definition: irods_exception.hpp:43
irods::stacktrace
Definition: irods_stacktrace.hpp:11
irods::exception::line_number_
uint32_t line_number_
Definition: irods_exception.hpp:57
irods::exception::code
int64_t code() const
Definition: irods_exception.hpp:39
irods::exception::~exception
virtual ~exception()
Definition: irods_exception.cpp:41
irods::exception::assemble_full_display_what
void assemble_full_display_what() const
Definition: irods_exception.cpp:59
irods::exception::code_
int64_t code_
Definition: irods_exception.hpp:55
irods
Definition: apiHandler.hpp:35
irods::exception::message_stack_
std::vector< std::string > message_stack_
Definition: irods_exception.hpp:56
irods::exception::file_name_
std::string file_name_
Definition: irods_exception.hpp:59
irods::exception::client_display_what
virtual const char * client_display_what() const
Definition: irods_exception.cpp:52
irods::exception::function_name_
std::string function_name_
Definition: irods_exception.hpp:58
irods::exception::message_stack
std::vector< std::string > message_stack() const
Definition: irods_exception.hpp:40
irods::exception::what_
std::string what_
Definition: irods_exception.hpp:61
irods::exception
Definition: irods_exception.hpp:15
irods::exception::assemble_client_display_what
void assemble_client_display_what() const
Definition: irods_exception.cpp:83
irods::exception::file_name
std::string file_name() const
Definition: irods_exception.hpp:41
irods::exception::add_message
void add_message(const std::string &_m)
Definition: irods_exception.hpp:47
irods::exception::what
virtual const char * what() const
Definition: irods_exception.cpp:46