In file Error.h:

class Error

A class for error processing.

Inheritance:


Public Methods

Error(const Error ©_from)
Copy constructor for Error class
Error& operator=(const Error &rhs)
The assignment operator copies the error correction
bool OK()
Is the Error object valid?
bool parse(FILE *fp)
Parse an Error object.
void print(ostream &os = cout)
Print the Error object on the given output stream.
ErrorCode error_code(ErrorCode ec = undefined_error)
Get or set the error code.
string error_message(string msg = "")
Get or set the error code.
void display_message(Gui *gui = 0)
Display the error message in a dialog box or on stderr.
ProgramType program_type(ProgramType pt = undefined_prog_type)
Get or set the program type.
char* program(char *program = 0)
Get or set the error correction program.
string correct_error(Gui *gui)
Run the error correction program or print the error message.

Public

Constructors
Constructors for the Error object
Error(ErrorCode ec, string msg)
Error(ErrorCode ec, string msg, ProgramType pt, char *pgm)
Error()

Documentation

The Error class is used to transport error information from the server to the client within DODS. It can also be used on the client side only. Errors consist of an error code, string and optionally a function/program. 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. The program or function can be used for error correction controlled by 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.
Constructors
It is not possible to create an Error object with only an error code; you must supply at a minimum a code and a message. In this case the correction program and program type will be null. In addition, if a program type is given a program {\it must} also be given. Other class constructors should be the only callers of this object's default constructor.

Error(ErrorCode ec, string msg)

Error(ErrorCode ec, string msg, ProgramType pt, char *pgm)

Error()

Error(const Error ©_from)
Copy constructor for Error class

Error& operator=(const Error &rhs)
The assignment operator copies the error correction

bool OK()
Use this function to determine whether an Error object is valid. An Error object is valid if it contains either an error code and message and an optional program type and program.
Returns:
TRUE if the object is valid, FALSE otherwise.

bool 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 DODS client might receive an error object from a server.
Returns:
TRUE if no error was detected, FALSE otherwise.
Parameters:
fp - A valid file pointer to an input stream.

void print(ostream &os = cout)
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() memeber function. Thus parse and print form a symetrical pair that can be used to send and receive an Error object over the network in a MIME document.
Parameters:
os - A pointer to the output stream on which the Error object is to be rendered.

ErrorCode error_code(ErrorCode ec = undefined_error)
With no argument, returns the Error object's error code. With an argument, sets the error code to that value.
Returns:
The Error object's error code.
Parameters:
ec - The error code. If this is not included, the undefined error code will be stored.

string error_message(string msg = "")
With no argument, return a copy of the objet's error message string. With an argument, set the object's error message to that string.
Returns:
A copy of the Error object's message string.
Parameters:
msg - The error message string. If this is omitted, the function simply returns a copy of the current message string.

void display_message(Gui *gui = 0)
Either display the error message in a dialog box and offer the user a single `OK' button or print the message to standard error. If #gui# is not given, then use stderr. In addition, the class Gui provides other means for the user to control how messages are displayed and those may be used to select either graphical or text devices.
Parameters:
gui - A pointer to a valid Gui class instance. This would be attached to a GUI process running on a client machine, and that process will display the message. If the pointer is not provided, the message will be displayed on the client's stderr.
See Also:
Gui

ProgramType program_type(ProgramType pt = undefined_prog_type)
With no argument, return the program type of the error object. With an argument, set the error object's program type field.
Returns:
The program type of the object.
See Also:
ProgramType

char* program(char *program = 0)
With no argument, return the error correction program. With an argument, set the error correction program to a copy of that value. Note that this is not a pointer to a function, but a character string containing the entire tcl, Java, or other program.
Returns:
the error correction program.

string correct_error(Gui *gui)
This function runs the error correction program, if possible, and returns a string that can be used as the `corrected' value. If there is no error correction program or it is not possible to run the program, the function simply displays the error message. If the error correction program cannot be run, the function returns the null string.
Returns:
A corrected string or "".
Parameters:
gui - A pointer to a Gui class object handling a GUI process on the client.
See Also:
Gui


Direct child classes:
InternalErr
Author:
jhrg

alphabetic index hierarchy of classes


generated by doc++