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