Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

wverror.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * A class for managing error numbers and strings.
00006  */ 
00007 #ifndef __WVERROR_H
00008 #define __WVERROR_H
00009 
00010 #include "wvstring.h"
00011 
00012 /**
00013  * A class for managing error numbers and strings.
00014  *
00015  * It can have either a system error value, like those defined
00016  * in errno.h, or an arbitrary error string.  In either case, it
00017  * can return a string representation of the error message.
00018  */
00019 class WvError
00020 {
00021 protected:
00022     int errnum;
00023     WvString errstring;
00024     
00025 public:
00026     WvError()
00027         { noerr(); }
00028     virtual ~WvError();
00029 
00030     /**
00031      * By default, returns true if geterr() == 0.
00032      * Might be overridden so that isok() == false even though no
00033      * error code has been specified.
00034      */
00035     virtual bool isok() const
00036         { return errnum == 0; }
00037 
00038     /**
00039      * If isok() is false, return the system error number corresponding to
00040      * the error, -1 for a special error string (which you can obtain with
00041      * errstr()) or 0 on end of file.  If isok() is true, returns an
00042      * undefined number.
00043      */ 
00044     virtual int geterr() const
00045         { return errnum; }
00046     virtual WvString errstr() const;
00047     
00048     /**
00049      * Set the errnum variable -- we have an error.  If called more than
00050      * once, seterr() doesn't change the error code away from the previous
00051      * one.  That way, we remember the _original_ cause of our problems.
00052      * 
00053      * Subclasses may want to override seterr(int) to shut themselves down
00054      * (eg. WvStream::close()) when an error condition is set.
00055      * 
00056      * Note that seterr(WvString) will call seterr(-1).
00057      */
00058     virtual void seterr(int _errnum);
00059     void seterr(WvStringParm specialerr);
00060     void seterr(WVSTRING_FORMAT_DECL)
00061         { seterr(WvString(WVSTRING_FORMAT_CALL)); }
00062     void seterr(const WvError &err);
00063     
00064     /** Reset our error state - there's no error condition anymore. */
00065     void noerr()
00066         { errnum = 0; }
00067 };
00068 
00069 
00070 #endif // __WVERROR_H

Generated on Wed Dec 15 15:08:11 2004 for WvStreams by  doxygen 1.3.9.1