libdap++ Updated for version 3.8.2
|
A class for error processing. More...
#include <Error.h>
Public Member Functions | |
Error (ErrorCode ec, string msg) | |
Error (string msg) | |
Error (const Error ©_from) | |
Error () | |
ErrorCode | get_error_code () const |
string | get_error_message () const |
bool | OK () const |
Is the Error object valid? | |
Error & | operator= (const Error &rhs) |
bool | parse (FILE *fp) |
Parse an Error object. | |
void | print (FILE *out) const |
void | print (ostream &out) const |
void | set_error_code (ErrorCode ec=undefined_error) |
void | set_error_message (string msg="") |
virtual | ~Error () |
Protected Attributes | |
ErrorCode | _error_code |
string | _error_message |
The Error class is used to transport error information from the server to the client within libdap. This class is also the base class for all the errors thrown by methods in the DAP, so catching Error will catch all DAP throws. Errors consist of an error code and a string. The code can be used to quickly distinguish between certain common errors while the string is used to convey information about the error to the user. The error code should never be displayed to the user.
This class is used on both clients and servers. The print() and parse() methods are used to send the object back and forth.
libdap::Error::Error | ( | ErrorCode | ec, |
string | msg | ||
) |
Create an instance with a specific code and message string. This ctor provides a way to to use any code and string you'd like. The code can be one of the standard codes or it may be specific to your server. Thus a client which can tell it's dealing with a specific type of server can use the code accordingly. In general, clients simply show the error message to users or write it to a log file.
ec | The error code |
msg | The error message string. |
libdap::Error::Error | ( | string | msg | ) |
libdap::Error::Error | ( | ) |
ErrorCode libdap::Error::get_error_code | ( | ) | const |
Get the ErrorCode for this instance.
Definition at line 250 of file Error.cc.
References _error_code, and OK().
string libdap::Error::get_error_message | ( | ) | const |
Return the current error message.
Definition at line 279 of file Error.cc.
References _error_message, and OK().
Referenced by libdap::HTTPCache::cache_response(), main(), parse(), and libdap::HTTPCache::~HTTPCache().
bool libdap::Error::OK | ( | ) | const |
Use this function to determine whether an Error object is valid. To be a valid, an Error object must either be: 1) empty or contain a message and a code.
Definition at line 136 of file Error.cc.
References _error_code, _error_message, DBG, and undefined_error.
Referenced by get_error_code(), get_error_message(), operator=(), parse(), and print().
Definition at line 113 of file Error.cc.
References _error_code, _error_message, and OK().
bool libdap::Error::parse | ( | FILE * | fp | ) |
Given an input stream (FILE *) fp
, parse an Error object from stream. Values for fields of the Error object are parsed and this
is set accordingly. This is how a client program receives an error object from a server.
fp | A valid file pointer to an input stream. |
Definition at line 159 of file Error.cc.
References Error_buffer(), Error_delete_buffer(), Error_switch_to_buffer(), Errorparse(), get_error_message(), OK(), and libdap::parser_arg::status().
Referenced by libdap::Connect::request_das(), libdap::Connect::request_das_url(), libdap::Connect::request_dds(), libdap::Connect::request_dds_url(), libdap::Connect::request_ddx(), and libdap::Connect::request_ddx_url().
void libdap::Error::print | ( | ostream & | strm | ) | const |
Creates a printable representation of the Error object. It is suitable for framing, and also for printing and sending over a network.
The printed representation produced by this function can be parsed by the parse() member function. Thus parse and print form a symmetrical pair that can be used to send and receive an Error object over the network in a MIME document.
strm | A reference to the output stream on which the Error object is to be rendered. |
Definition at line 230 of file Error.cc.
References _error_code, _error_message, and OK().
void libdap::Error::print | ( | FILE * | out | ) | const |
Creates a printable representation of the Error object. It is suitable for framing, and also for printing and sending over a network.
The printed representation produced by this function can be parsed by the parse() member function. Thus parse and print form a symmetrical pair that can be used to send and receive an Error object over the network in a MIME document.
out | A pointer to the output stream on which the Error object is to be rendered. |
Definition at line 201 of file Error.cc.
References _error_code, _error_message, and OK().
void libdap::Error::set_error_code | ( | ErrorCode | ec = undefined_error | ) |
Set the ErrorCode. If the current error message has not been set, use ec to set the error message. The resulting error message string is the same as the ErrorCode name. If ec is not within the range of values for an OPeNDAP ErrorCode, the error message is left unchanged.
ec | The new ErrorCode value. |
Definition at line 263 of file Error.cc.
References _error_code, _error_message, cannot_read_file, and undefined_error.
void libdap::Error::set_error_message | ( | string | msg = "" | ) |
ErrorCode libdap::Error::_error_code [protected] |
Definition at line 93 of file Error.h.
Referenced by get_error_code(), libdap::InternalErr::InternalErr(), OK(), operator=(), print(), libdap::ResponseTooBigErr::ResponseTooBigErr(), set_error_code(), and libdap::SignalHandlerRegisteredErr::SignalHandlerRegisteredErr().
string libdap::Error::_error_message [protected] |
Definition at line 94 of file Error.h.
Referenced by get_error_message(), libdap::InternalErr::InternalErr(), OK(), operator=(), print(), libdap::ResponseTooBigErr::ResponseTooBigErr(), set_error_code(), set_error_message(), and libdap::SignalHandlerRegisteredErr::SignalHandlerRegisteredErr().