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();