35using std::istringstream;
40#include "BESShowErrorResponseHandler.h"
41#include "BESDataNames.h"
42#include "BESInternalError.h"
43#include "BESInternalFatalError.h"
44#include "BESSyntaxUserError.h"
45#include "BESForbiddenError.h"
46#include "BESNotFoundError.h"
47#include "BESDataHandlerInterface.h"
49BESShowErrorResponseHandler::BESShowErrorResponseHandler(
const string &name) :
54BESShowErrorResponseHandler::~BESShowErrorResponseHandler()
74 string etype_s = dhi.
data[SHOW_ERROR_TYPE];
75 if (etype_s.empty()) {
76 string err = dhi.
action +
" error type missing";
79 istringstream strm(etype_s);
80 unsigned int etype = 0;
82 if (!etype || etype > 5) {
83 string err = dhi.
action +
" invalid error type, should be 1-5";
88 case BES_INTERNAL_ERROR: {
89 string err = dhi.
action +
" Internal Error";
92 case BES_INTERNAL_FATAL_ERROR: {
93 string err = dhi.
action +
" Internal Fatal Error";
96 case BES_SYNTAX_USER_ERROR: {
97 string err = dhi.
action +
" Syntax User Error";
100 case BES_FORBIDDEN_ERROR: {
101 string err = dhi.
action +
" Forbidden Error";
104 case BES_NOT_FOUND_ERROR: {
105 string err = dhi.
action +
" Not Found Error";
125 string err =
"An exception should have been thrown, nothing to transmit";
137 strm << BESIndent::LMarg <<
"BESShowErrorResponseHandler::dump - (" << (
void *)
this <<
")" << endl;
140 BESIndent::UnIndent();
144BESShowErrorResponseHandler::ResponseBuilder(
const string &name)
Structure storing information used by the BES to handle the request.
std::map< std::string, std::string > data
the map of string data that will be required for the current request.
std::string action
the response object requested, e.g. das, dds
error thrown if the BES is not allowed to access the resource requested
exception thrown if internal error encountered
exception thrown if an internal error is found and is fatal to the BES
error thrown if the resource requested cannot be found
handler object that knows how to create a specific response object
void dump(std::ostream &strm) const override
dumps information about this object
response handler that throws the requested exception type
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)
transmit the response object built by the execute command using the specified transmitter object
virtual void execute(BESDataHandlerInterface &dhi)
throws a specific exception to test error handling in clients
virtual void dump(std::ostream &strm) const
dumps information about this object
error thrown if there is a user syntax error in the request or any other user error