36 using std::ostringstream;
38 #include "BESDapError.h" 39 #include "BESContextManager.h" 40 #include "BESDapErrorInfo.h" 43 #include "BESInfoList.h" 44 #include "TheBESKeys.h" 47 BESDapError::BESDapError(
const string &s,
bool fatal, libdap::ErrorCode ec,
const string &file,
int line) :
48 BESError(s, 0, file, line), d_dap_error_code(ec)
50 set_bes_error_type(convert_error_code(ec, fatal));
54 set_bes_error_type(BES_INTERNAL_FATAL_ERROR);
56 set_bes_error_type(BES_INTERNAL_ERROR);
85 if (current_error_type == BES_INTERNAL_FATAL_ERROR)
return current_error_type;
90 return BES_INTERNAL_ERROR;
93 case internal_error: {
94 return BES_INTERNAL_FATAL_ERROR;
98 return BES_NOT_FOUND_ERROR;
101 case no_such_variable:
102 case malformed_expr: {
103 return BES_SYNTAX_USER_ERROR;
106 case no_authorization:
107 case cannot_read_file:
108 case dummy_message: {
109 return BES_FORBIDDEN_ERROR;
113 return BES_INTERNAL_ERROR;
121 return convert_error_code(error_code, (fatal) ? BES_INTERNAL_FATAL_ERROR: BES_INTERNAL_ERROR);
127 string error_name =
"";
130 bool only_log_to_verbose =
false;
132 case BES_INTERNAL_FATAL_ERROR:
133 error_name =
"BES Internal Fatal Error";
136 case BES_INTERNAL_ERROR:
137 error_name =
"BES Internal Error";
140 case BES_SYNTAX_USER_ERROR:
141 error_name =
"BES User Syntax Error";
142 only_log_to_verbose =
false;
145 case BES_FORBIDDEN_ERROR:
146 error_name =
"BES Forbidden Error";
149 case BES_NOT_FOUND_ERROR:
150 error_name =
"BES Not Found Error";
151 only_log_to_verbose =
false;
155 error_name =
"Unrecognized BES Error";
159 if (only_log_to_verbose) {
165 LOG(
"ERROR: " << error_name <<
": " << e.
get_message() << endl);
185 void BESDapError::add_ehm_callback(ptr_bes_ehm ehm)
187 _ehm_list.push_back(ehm);
197 for (ehm_iter i = _ehm_list.begin(), ei = _ehm_list.end(); i != ei; ++i) {
199 int handled = p(e, dhi);
205 dhi.
error_info = BESInfoList::TheList()->build_info();
206 string action_name = dhi.action_name;
207 if (action_name.empty()) action_name =
"BES";
210 string administrator =
"";
214 string key =
"BES.ServerAdministrator";
218 administrator = DEFAULT_ADMINISTRATOR;
220 if (administrator.empty()) {
221 administrator = DEFAULT_ADMINISTRATOR;
249 string context = BESContextManager::TheManager()->
get_context(
"errors", found);
250 if (context ==
"dap2" | context ==
"dap") {
251 ErrorCode ec = unknown_error;
270 s <<
"libdap exception building response: error_code = " << de->
get_dap_error_code() <<
": " 283 string context = BESContextManager::TheManager()->
get_context(
"errors", found);
284 if (context ==
"dap2") {
285 ErrorCode ec = unknown_error;
304 s <<
"libdap exception building response: error_code = " << de->
get_dap_error_code() <<
": " 325 strm << BESIndent::LMarg <<
"BESDapError::dump - (" << (
void *)
this <<
")" << endl;
329 BESIndent::UnIndent();
int convert_error_code(int error_code, int current_error_type)
converts the libdap error code to the bes error type
silent informational response object
virtual std::string get_message()
get the error message for this exception
virtual void dump(std::ostream &strm) const
Displays debug information about this object.
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
virtual string get_context(const string &name, bool &found)
retrieve the value of the specified context from the BES
virtual void dump(ostream &strm) const
dumps information about this object
Abstract exception class for the BES with basic string message.
static TheBESKeys * TheKeys()
virtual void add_exception(BESError &e, const string &admin)
add exception information to this informational object
error object created from libdap error objects and can handle those errors
virtual int get_dap_error_code() const
virtual void set_message(const std::string &msg)
set the error message for this exception
Structure storing information used by the BES to handle the request.
virtual std::string get_file()
get the file name where the exception was thrown
virtual void set_bes_error_type(int type)
Set the return code for this particular error class.
virtual int get_bes_error_type()
Return the return code for this error class.
virtual void begin_response(const string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
BESInfo * error_info
error information object
virtual int get_line()
get the line number where the exception was thrown