Exception.hpp
#if !defined (__EXCEPTION_HPP)
#define __EXCEPTION_HPP
/*
CoreLinux++
Copyright (C) 1999 CoreLinux Consortium
The CoreLinux++ Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The CoreLinux++ Library Library is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#if !defined IN_COMMON_HPP
#error except.hpp is included by common.hpp only.
#endif
#include <string>
//
// Base exception class
//
namespace corelinux
{
DECLARE_CLASS( Exception );
// Define a reference to line number
DECLARE_TYPE( Dword, LineNum );
class Exception
{
public:
enum Severity
{
CONTINUABLE = 1,
THREADFATAL,
PROCESSFATAL,
THREADTERMINATE,
PROCESSTERMINATE
};
Exception
(
CharCptr why,
CharCptr file,
LineNum line,
Severity severity = Exception::CONTINUABLE,
bool outOfMemory = false
);
Exception( ExceptionCref crOther );
virtual ~Exception(void);
//
// Operator overloads
//
ExceptionRef operator = ( ExceptionCref otherRef );
bool operator==( ExceptionCref otherRef );
//
// Accessor methods
//
const std::string & getFile( void ) const;
LineNumCref getLine( void ) const;
const std::string & getWhy( void ) const;
const Severity & getSeverity( void ) const;
const std::string & getUnwind( void ) const;
bool isOutOfMemory( void ) const
{ return theOutOfMemoryFlag;}
//
// Mutator methods
//
void addUnwindInfo( CharCptr unwindInfo );
void setThreadFatalSeverity( void );
void setProcessFatalSeverity( void );
void setThreadTerminateSeverity( void );
void setProcessTerminateSeverity( void );
protected:
Exception( void );
Exception
(
CharCptr file,
LineNum line,
Severity severity = Exception::CONTINUABLE,
bool outOfMemory = false
);
void setWhy( const std::string & );
void setWhy( CharCptr );
private:
private:
// Reason why the exception is being thrown.
std::string theReason;
// File that threw the exception.
std::string theFile;
// Severity of the exception.
Severity theSeverity;
// Unwind information added as exception is unwound from
// stack.
std::string theUnwindInfo;
// Line number in the file throwing the exception.
LineNum theLine;
// Flag that indicates if there is a low memory situation.
bool theOutOfMemoryFlag;
};
}
#endif // !defined __EXCEPTION_HPP
/*
Common rcs information do not modify
$Author: frankc $
$Revision: 1.2 $
$Date: 2000/07/28 01:37:09 $
$Locker: $
*/
corelinux::Exception::PROCESSFATAL
Exception may prove to be thread fatal.
Definition: Exception.hpp:63
corelinux::Exception::getLine
LineNumCref getLine(void) const
Accessor.
Definition: Exception.cpp:144
corelinux::Exception::operator==
bool operator==(ExceptionCref otherRef)
Comparisson operator overload.
Definition: Exception.cpp:134
corelinux::Exception::~Exception
virtual ~Exception(void)
Virtual Destructor.
Definition: Exception.cpp:102
corelinux::Exception::addUnwindInfo
void addUnwindInfo(CharCptr unwindInfo)
Append unwind information to the Exception.
Definition: Exception.cpp:165
corelinux::Exception::setThreadFatalSeverity
void setThreadFatalSeverity(void)
Change the severity to Severity::THREADFATAL.
Definition: Exception.cpp:178
corelinux::Exception::getWhy
const std::string & getWhy(void) const
Accessor.
Definition: Exception.cpp:149
corelinux::Exception::PROCESSTERMINATE
System should kill thread.
Definition: Exception.hpp:65
corelinux::Exception::setThreadTerminateSeverity
void setThreadTerminateSeverity(void)
Change the severity to Severity::THREADTERMINATE.
Definition: Exception.cpp:203
corelinux::Exception::Exception
Exception(void)
Exceptions must have a reason.
Definition: Exception.cpp:93
corelinux::Exception::setWhy
void setWhy(const std::string &)
Changes the exception reason.
Definition: Exception.cpp:227
corelinux::Exception::Severity
Severity
Exception Severity States.
Definition: Exception.hpp:59
corelinux::Exception::operator=
ExceptionRef operator=(ExceptionCref otherRef)
Assignment operator overload.
Definition: Exception.cpp:111
corelinux::Exception::getSeverity
const Severity & getSeverity(void) const
Accessor.
Definition: Exception.cpp:154
corelinux::Exception
Exception is the base exception class used in the CoreLinux++ libraries.
Definition: Exception.hpp:51
corelinux::Exception::getFile
const std::string & getFile(void) const
Accessor.
Definition: Exception.cpp:139
corelinux::Exception::THREADTERMINATE
Exception may prove to be process fatal.
Definition: Exception.hpp:64
corelinux::Exception::getUnwind
const std::string & getUnwind(void) const
Accessor.
Definition: Exception.cpp:160
corelinux::Exception::setProcessTerminateSeverity
void setProcessTerminateSeverity(void)
Change the severity to Severity::PROCESSTERMINATE.
Definition: Exception.cpp:215
corelinux::Exception::isOutOfMemory
bool isOutOfMemory(void) const
Accessor.
Definition: Exception.hpp:164
corelinux::Exception::THREADFATAL
System can continue processing.
Definition: Exception.hpp:62
corelinux::Exception::setProcessFatalSeverity
void setProcessFatalSeverity(void)
Change the severity to Severity::PROCESSFATAL.
Definition: Exception.cpp:191

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium