36 using std::ostringstream;
39 #include "BESDapError.h"
40 #include "BESContextManager.h"
41 #include "BESDapErrorInfo.h"
44 #include "BESInfoList.h"
45 #include "TheBESKeys.h"
48 BESDapError::BESDapError(
const string &s,
bool fatal, libdap::ErrorCode ec,
const string &file,
int line) :
49 BESError(s, 0, file, line), d_dap_error_code(ec)
51 set_bes_error_type(convert_error_code(ec, fatal));
55 set_bes_error_type(BES_INTERNAL_FATAL_ERROR);
57 set_bes_error_type(BES_INTERNAL_ERROR);
86 if (current_error_type == BES_INTERNAL_FATAL_ERROR)
return current_error_type;
91 return BES_INTERNAL_ERROR;
94 case internal_error: {
95 return BES_INTERNAL_FATAL_ERROR;
99 return BES_NOT_FOUND_ERROR;
102 case no_such_variable:
103 case malformed_expr: {
104 return BES_SYNTAX_USER_ERROR;
107 case no_authorization:
108 case cannot_read_file:
109 case dummy_message: {
110 return BES_FORBIDDEN_ERROR;
114 return BES_INTERNAL_ERROR;
122 return convert_error_code(error_code, (fatal) ? BES_INTERNAL_FATAL_ERROR: BES_INTERNAL_ERROR);
128 string error_name =
"";
131 bool only_log_to_verbose =
false;
133 case BES_INTERNAL_FATAL_ERROR:
134 error_name =
"BES Internal Fatal Error";
137 case BES_INTERNAL_ERROR:
138 error_name =
"BES Internal Error";
141 case BES_SYNTAX_USER_ERROR:
142 error_name =
"BES User Syntax Error";
143 only_log_to_verbose =
false;
146 case BES_FORBIDDEN_ERROR:
147 error_name =
"BES Forbidden Error";
150 case BES_NOT_FOUND_ERROR:
151 error_name =
"BES Not Found Error";
152 only_log_to_verbose =
false;
156 error_name =
"Unrecognized BES Error";
160 if (only_log_to_verbose) {
166 LOG(
"ERROR: " << error_name <<
": " << e.
get_message() << endl);
186 void BESDapError::add_ehm_callback(ptr_bes_ehm ehm)
188 _ehm_list.push_back(ehm);
198 for (ehm_iter i = _ehm_list.begin(), ei = _ehm_list.end(); i != ei; ++i) {
200 int handled = p(e, dhi);
206 dhi.
error_info = BESInfoList::TheList()->build_info();
207 string action_name = dhi.action_name;
208 if (action_name.empty()) action_name =
"BES";
211 string administrator =
"";
215 string key =
"BES.ServerAdministrator";
219 administrator = DEFAULT_ADMINISTRATOR;
221 if (administrator.empty()) {
222 administrator = DEFAULT_ADMINISTRATOR;
250 string context = BESContextManager::TheManager()->
get_context(
"errors", found);
251 if (context ==
"dap2" | context ==
"dap") {
252 ErrorCode ec = unknown_error;
271 s <<
"libdap exception building response: error_code = " << de->
get_dap_error_code() <<
": "
284 string context = BESContextManager::TheManager()->
get_context(
"errors", found);
285 if (context ==
"dap2") {
286 ErrorCode ec = unknown_error;
305 s <<
"libdap exception building response: error_code = " << de->
get_dap_error_code() <<
": "
326 strm << BESIndent::LMarg <<
"BESDapError::dump - (" << (
void *)
this <<
")" << endl;
330 BESIndent::UnIndent();
virtual std::string get_context(const std::string &name, bool &found)
retrieve the value of the specified context from the BES
silent informational response object
error object created from libdap error objects and can handle those errors
int convert_error_code(int error_code, int current_error_type)
converts the libdap error code to the bes error type
virtual void dump(ostream &strm) const
dumps information about this object
virtual int get_dap_error_code() const
Structure storing information used by the BES to handle the request.
BESInfo * error_info
error information object
Abstract exception class for the BES with basic string message.
virtual int get_bes_error_type()
Return the return code for this error class.
virtual void set_bes_error_type(int type)
Set the return code for this particular error class.
virtual int get_line()
get the line number where the exception was thrown
virtual void dump(std::ostream &strm) const
Displays debug information about this object.
virtual std::string get_file()
get the file name where the exception was thrown
virtual std::string get_message()
get the error message for this exception
virtual void set_message(const std::string &msg)
set the error message for this exception
virtual void begin_response(const std::string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
virtual void add_exception(BESError &e, const std::string &admin)
add exception information to this informational object
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
static TheBESKeys * TheKeys()