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.cpp
Go to the documentation of this file.
1 #include "irods_exception.hpp"
2 #include "irods_stacktrace.hpp"
3 #include "rodsLog.h"
4 
5 namespace irods {
6 
8  const int64_t _code,
9  const std::string& _message,
10  const std::string& _file_name,
11  const uint32_t _line_number,
12  const std::string& _function_name ) :
13  std::exception(),
14  code_( _code ),
15  line_number_( _line_number ),
16  stacktrace_() {
17  message_stack_.push_back( _message );
18  file_name_ = _file_name;
19  function_name_ = _function_name;
20 
21  } // exception
22 
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::exception(_code, boost::str(_message), _file_name, _line_number, _function_name) {}
30 
32  std::exception( _rhs ),
33  code_( _rhs.code_ ),
34  message_stack_( _rhs.message_stack_ ),
35  line_number_( _rhs.line_number_ ),
36  function_name_( _rhs.function_name_ ),
37  file_name_( _rhs.file_name_ ),
38  stacktrace_( _rhs.stacktrace_ ) {
39  }
40 
42 
43  } // ~exception
44 
45  // This "should not" be called from the icommands
46  const char* exception::what() const throw()
47  {
49  return what_.c_str();
50  }
51 
52  const char* exception::client_display_what() const throw()
53  {
55  return what_.c_str();
56  }
57 
58  // Modifies the what_ string for a full what() message
60  {
61  std::stringstream what_ss;
62 
63  what_ss << "iRODS Exception:"
64  << "\n file: " << file_name_
65  << "\n function: " << function_name_
66  << "\n line: " << line_number_
67  << "\n code: " << code_ << " (" << rodsErrorName( static_cast<int>(code_), NULL ) << ")"
68  << "\n message:" << "\n";
69 
70  for ( auto entry: message_stack_)
71  {
72  what_ss << " " << entry << "\n";
73  }
74 
75  what_ss << "stack trace:" << "\n"
76  << "--------------" << "\n"
77  << stacktrace_.dump() << std::endl;
78 
79  what_ = what_ss.str();
80  }
81 
82  // Modifies the what_ string for a client display suitable what() message
84  {
85  std::stringstream what_ss;
86 
87  what_ss << rodsErrorName( static_cast<int>(code_), NULL ) << ": ";
88 
89  for ( auto entry: message_stack_)
90  {
91  what_ss << entry << "\n";
92  }
93  what_ss << std::endl;
94  what_ = what_ss.str();
95  }
96 
97 }; // namespace irods
NULL
#define NULL
Definition: rodsDef.h:70
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::stacktrace::dump
const std::string & dump() const
Definition: irods_stacktrace.cpp:55
irods::exception::stacktrace_
irods::stacktrace stacktrace_
Definition: irods_exception.hpp:60
irods_stacktrace.hpp
irods_exception.hpp
boost
Definition: rcMisc.cpp:4341
irods::exception::line_number_
uint32_t line_number_
Definition: irods_exception.hpp:57
rodsErrorName
const char * rodsErrorName(int errorValue, char **subName)
Definition: rodsLog.cpp:373
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
rodsLog.h
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
entry
Definition: ruleAdmin.cpp:22
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::what
virtual const char * what() const
Definition: irods_exception.cpp:46