Error Class Reference

A class for error processing. More...

#include <Error.h>

Inheritance diagram for Error:

Inheritance graph
[legend]
Collaboration diagram for Error:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Error (const Error &copy_from)
 Copy constructor.
 Error ()
 Create a default Error object.
 Error (string msg)
 Create an instance with the unknown_error code.
 Error (ErrorCode ec, string msg)
 Create an instance with an error code and a message.
ErrorCode get_error_code () const
 Get the error code.
string get_error_message () const
 Get the error message.
bool OK () const
 Class invariant.
Erroroperator= (const Error &rhs)
bool parse (FILE *fp)
 Deserialize object from the wire.
void print (FILE *out) const
 Print the Error object on the given output stream.
void set_error_code (ErrorCode ec=undefined_error)
 Set the error code.
void set_error_message (string msg="")
 Set the error message.
virtual ~Error ()

Protected Attributes

ErrorCode _error_code
string _error_message
char * _program
 deprecated; don't use
ProgramType _program_type
 deprecated; don't use

Detailed Description

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.

Note:
A past version of this class supported the notion of an error correcting program (Tcl, Java, ...) that could be sent from the server to the client to help users correct the error and resubmit the request. This never worked well in practice and that feature of the class is deprecated.
Author:
jhrg

Definition at line 95 of file Error.h.


Constructor & Destructor Documentation

Error::Error ( ErrorCode  ec,
string  msg 
)

Error::Error ( string  msg  ) 

Create an instance with a specific message. The error code is set to unknown_error.

Parameters:
msg The error message.
See also:
ErrorCode

Definition at line 91 of file Error.cc.

Error::Error (  ) 

Specializations of Error should use this to set the error code and message.

Definition at line 67 of file Error.cc.

Error::Error ( const Error copy_from  ) 

Definition at line 105 of file Error.cc.

References _program.

Error::~Error (  )  [virtual]

Definition at line 116 of file Error.cc.

References _program.


Member Function Documentation

ErrorCode Error::get_error_code (  )  const

Get the ErrorCode for this instance.

Definition at line 262 of file Error.cc.

References _error_code, and OK().

Here is the call graph for this function:

string Error::get_error_message (  )  const

Return the current error message.

Definition at line 299 of file Error.cc.

References _error_message, and OK().

Referenced by main(), AISMerge::merge(), and parse().

Here is the call graph for this function:

bool 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.

Returns:
TRUE if the object is valid, FALSE otherwise.

Definition at line 152 of file Error.cc.

References _error_code, _error_message, DBG, and undefined_error.

Referenced by get_error_code(), get_error_message(), InternalErr::OK(), operator=(), parse(), and print().

Error & Error::operator= ( const Error rhs  ) 

Definition at line 122 of file Error.cc.

References _error_code, _error_message, _program, _program_type, and OK().

Here is the call graph for this function:

bool 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.

Parameters:
fp A valid file pointer to an input stream.
Returns:
TRUE if no error was detected, FALSE otherwise.

Definition at line 175 of file Error.cc.

References Error_buffer(), Error_delete_buffer(), Error_switch_to_buffer(), Errorparse(), get_error_message(), OK(), and parser_arg::status().

Referenced by Connect::request_das(), Connect::request_das_url(), Connect::request_dds(), Connect::request_dds_url(), Connect::request_ddx(), and Connect::request_ddx_url().

Here is the call graph for this function:

void 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.

Parameters:
out A pointer to the output stream on which the Error object is to be rendered.

Definition at line 217 of file Error.cc.

References _error_code, _error_message, _program, _program_type, OK(), and undefined_prog_type.

Referenced by AlarmHandler::handle_signal().

Here is the call graph for this function:

void Error::set_error_code ( ErrorCode  ec = undefined_error  ) 

void Error::set_error_message ( string  msg = ""  ) 

Set the error message.

Definition at line 308 of file Error.cc.

References _error_message.


Member Data Documentation

ErrorCode Error::_error_code [protected]

Definition at line 98 of file Error.h.

Referenced by get_error_code(), InternalErr::InternalErr(), OK(), operator=(), print(), ResponseTooBigErr::ResponseTooBigErr(), and SignalHandlerRegisteredErr::SignalHandlerRegisteredErr().

string Error::_error_message [protected]

Definition at line 99 of file Error.h.

Referenced by get_error_message(), InternalErr::InternalErr(), OK(), operator=(), print(), ResponseTooBigErr::ResponseTooBigErr(), set_error_message(), and SignalHandlerRegisteredErr::SignalHandlerRegisteredErr().

char* Error::_program [protected]

Definition at line 101 of file Error.h.

Referenced by Error(), operator=(), print(), and ~Error().

ProgramType Error::_program_type [protected]

Definition at line 100 of file Error.h.

Referenced by operator=(), and print().


The documentation for this class was generated from the following files:
Generated on Wed Jun 27 12:57:50 2007 for libdap++ by  doxygen 1.4.7