g+
g+ Communities
Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  Index 2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014 
<== Date ==> <== Thread ==>

Subject: 3.15 C++ Exception classes
From: Andrew Johnson <anj@aps.anl.gov>
To: EPICS core-talk <core-talk@aps.anl.gov>
Date: Mon, 20 Feb 2006 17:21:08 -0600
Last September, Jeff Hill sent me this class definition, with the suggestion that something like this be adopted as the basis for future EPICS exception objects:

struct Diagnostic : exception {
public:
enum severity_t { sevWarning, sevError, sevFatal };
    virtual severity_t severity () const = 0;
    virtual void context ( StringSegment & ) const = 0;
};

Having recently committed my StringReader and StringEditor interfaces and some implementations to the 3.15 CVS tree for Jeff to use in DataAccess, I am looking at designing a modified version of this class for general use. The main point of this email is to document what I'm currently implementing, but I guess that this may result in some discussion from Jeff and others as well.

severity(): I don't like this; the severity information should be implicit in the hierarchy of the class that is being thrown. I expect to be able to write a try/catch phrase that could catch warnings but not errors or fatalities; I don't want to catch everything and then have to re-throw anything that's more severe than a warning. I'm also not convinced that the thrower can determine the severity of an exception in practice. Therefore I'm not going to include the severity part.

context(): I'm replacing Jeff's StringSegment with a StringEditor and renaming this function to what(), since it performs the exact same role as the std::exception::what() function, namely provides a way to convert the exception data into a displayable string.

status(): We often provide wrappers to allow C code to call C++ code. The C routines can't trap exceptions, so those C++ wrappers may have to convert such exceptions into a long integer status value. The exception object is the obvious thing to know what status value to return, so I'm considering adding this method to provide that. If the conversion to the single C status value would lose diagnostic data that is stored in the exception object, this routine can log that information to the error logger at that time - status() should only be called once, when the exception is about to be passed to C code.

Here's my current replacement base class:

class BaseException :
    public std::exception {
public:
    virtual void what(StringEditor &str) const = 0;
    virtual long status() const {
        return S_exc_exception;
    }
};

- Andrew
--
There is no S in exprexxo.

Replies:
Re: 3.15 C++ Exception classes Kay-Uwe Kasemir
RE: 3.15 C++ Exception classes Jeff Hill

Navigate by Date:
Prev: Re: DBD Syntax (Arrays) Marty Kraimer
Next: Re: 3.15 C++ Exception classes Kay-Uwe Kasemir
Index: 2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014 
Navigate by Thread:
Prev: Re: DBD Syntax (Arrays) Marty Kraimer
Next: Re: 3.15 C++ Exception classes Kay-Uwe Kasemir
Index: 2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICSv4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·