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_error.hpp
Go to the documentation of this file.
1 #ifndef __IRODS_ERROR_HPP__
2 #define __IRODS_ERROR_HPP__
3 
4 // =-=-=-=-=-=-=-
5 // STL Includes
6 #include <string>
7 #include <vector>
8 #include <cstdarg>
9 
10 #include <boost/optional.hpp>
11 
12 // =-=-=-=-=-=-=-
13 // irods includes
14 #include "rodsType.h"
15 #include "irods_exception.hpp"
16 
17 #include <boost/assert.hpp>
18 #include <boost/format.hpp>
19 
20 namespace irods {
23  class error {
24  public:
25  // =-=-=-=-=-=-=-
26  // Constructors
27  error();
28  error(
29  bool, // status
30  long long, // error code
31  std::string, // message
32  std::string, // file name
33  int, // line number
34  std::string ); // function
35  error(
36  bool, // status
37  long long, // error code
38  boost::format, // message
39  std::string, // file name
40  int, // line number
41  std::string ); // function
42  error( // deprecated since 4.0.3
43  bool, // status
44  long long, // error code
45  std::string, // message
46  std::string, // file name
47  int, // line number
48  std::string, // function
49  const error& ); // previous error
50  error(
51  std::string, // message
52  std::string, // file name
53  int, // line number
54  std::string, // function
55  const error& ); // previous error
56  error( const error& );
57  error( const exception& );
58 
59  // =-=-=-=-=-=-=-
60  // Destructor
61  ~error();
62 
63  // =-=-=-=-=-=-=-
64  // Operators
65  error& operator=( const error& );
66 
67  // =-=-=-=-=-=-=-
68  // Members
69  bool status() const;
70  long long code() const;
71  std::string result() const;
72  std::string user_result() const;
73  bool ok(); // deprecated since 4.0.3
74  bool ok() const;
75 
76  // =-=-=-=-=-=-=-
77  // Mutators
78  void code( long long _code ) {
79  code_ = _code;
80  }
81  void status( bool _status ) {
82  status_ = _status;
83  }
84  void message( std::string _message ) {
85  message_ = _message;
86  }
87 
88  private:
89  // =-=-=-=-=-=-=-
90  // Attributes
91  bool status_;
92  long long code_;
93  std::string message_;
94  std::vector< std::string > result_stack_;
95  boost::optional< exception > exception_;
96 
97  // These are hard-coded strings that are used in creating
98  // the strings that go in result_stack_, and that are searched
99  // for as such. See static declarations in irods_error.cpp for initialization.
100  static const char *iRODS_token_;
101  static const char *colon_token_;
102  static const char *status_token_;
103 
104  // =-=-=-=-=-=-=-
105  // Members
106  std::string build_result_string( std::string, int, std::string );
107 
108  }; // class error
109 
110  error assert_error( bool expr_, long long code_, const std::string& file_, const std::string& function_, const std::string& format_, int line_, ... );
111  error assert_pass( const error& _error, const std::string& _file, const std::string& _function, const std::string& _format, int line_, ... );
112 
113 }; // namespace irods
114 
115 
116 
117 #define ERROR( code_, message_ ) ( irods::error( false, code_, message_, __FILE__, __LINE__, __PRETTY_FUNCTION__ ) )
118 #define PASS( prev_error_ ) (irods::error( "", __FILE__, __LINE__, __PRETTY_FUNCTION__, prev_error_ ) )
119 #define PASSMSG( message_, prev_error_ ) (irods::error( message_, __FILE__, __LINE__, __PRETTY_FUNCTION__, prev_error_ ) )
120 #define CODE( code_ ) ( irods::error( true, code_, "", __FILE__, __LINE__, __PRETTY_FUNCTION__ ) )
121 #define SUCCESS( ) ( irods::error( true, 0, "", __FILE__, __LINE__, __PRETTY_FUNCTION__ ) )
122 
123 #define ASSERT_ERROR(expr_, code_, format_, ...) (irods::assert_error(expr_, code_, __FILE__, __PRETTY_FUNCTION__, format_, __LINE__, ##__VA_ARGS__))
124 #define ASSERT_PASS(prev_error_, format_, ...) (irods::assert_pass(prev_error_, __FILE__, __PRETTY_FUNCTION__, format_, __LINE__, ##__VA_ARGS__))
125 
126 #endif // __IRODS_ERROR_HPP__
irods::error::user_result
std::string user_result() const
Definition: irods_error.cpp:229
irods::error::status_
bool status_
Definition: irods_error.hpp:91
irods::error::error
error()
Definition: irods_error.cpp:74
irods_exception.hpp
irods::assert_pass
error assert_pass(const error &_error, const std::string &_file, const std::string &_function, const std::string &_format, int line_,...)
Definition: irods_error.cpp:292
irods::error::message
void message(std::string _message)
Definition: irods_error.hpp:84
irods::error::colon_token_
static const char * colon_token_
Definition: irods_error.hpp:101
irods::error::code_
long long code_
Definition: irods_error.hpp:92
irods::error::exception_
boost::optional< exception > exception_
Definition: irods_error.hpp:95
irods::error::~error
~error()
Definition: irods_error.cpp:171
irods::error::code
long long code() const
Definition: irods_error.cpp:194
rodsType.h
irods::error::status_token_
static const char * status_token_
Definition: irods_error.hpp:102
irods
Definition: apiHandler.hpp:35
irods::error::code
void code(long long _code)
Definition: irods_error.hpp:78
irods::error::message_
std::string message_
Definition: irods_error.hpp:93
irods::assert_error
error assert_error(bool expr_, long long code_, const std::string &file_, const std::string &function_, const std::string &format_, int line_,...)
Definition: irods_error.cpp:269
irods::error
Definition: irods_error.hpp:23
irods::error::build_result_string
std::string build_result_string(std::string, int, std::string)
Definition: irods_error.cpp:27
irods::error::status
void status(bool _status)
Definition: irods_error.hpp:81
irods::exception
Definition: irods_exception.hpp:15
irods::error::status
bool status() const
Definition: irods_error.cpp:187
irods::error::iRODS_token_
static const char * iRODS_token_
Definition: irods_error.hpp:100
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods::error::result
std::string result() const
Definition: irods_error.cpp:201
irods::error::result_stack_
std::vector< std::string > result_stack_
Definition: irods_error.hpp:94
irods::error::operator=
error & operator=(const error &)
Definition: irods_error.cpp:176