1 // This file is part of the ustl library, an STL implementation.
3 // Copyright (C) 2005 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
9 #ifndef USTDXEPT_H_46F7AE967738B588038F95E41158D7FF
10 #define USTDXEPT_H_46F7AE967738B588038F95E41158D7FF
12 #include "uexception.h"
18 xfmt_ErrorMessage
= 2,
19 xfmt_LogicError
= xfmt_ErrorMessage
,
20 xfmt_RuntimeError
= xfmt_ErrorMessage
23 /// \class logic_error ustdxept.h ustl.h
24 /// \ingroup Exceptions
26 /// \brief Logic errors represent problems in the internal logic of the program.
28 class error_message
: public exception
{
30 explicit error_message (const char* arg
) throw();
31 virtual ~error_message (void) throw();
32 inline virtual const char* what (void) const throw() { return ("error"); }
33 virtual void info (string
& msgbuf
, const char* fmt
= NULL
) const throw();
34 virtual void read (istream
& is
);
35 virtual void write (ostream
& os
) const;
36 virtual size_t stream_size (void) const;
41 /// \class logic_error ustdxept.h ustl.h
42 /// \ingroup Exceptions
44 /// \brief Logic errors represent problems in the internal logic of the program.
46 class logic_error
: public error_message
{
48 inline explicit logic_error (const char* arg
) throw() : error_message (arg
) {}
49 inline virtual const char* what (void) const throw() { return ("logic error"); }
52 /// \class domain_error ustdxept.h ustl.h
53 /// \ingroup Exceptions
55 /// \brief Reports domain errors ("domain" is in the mathematical sense)
57 class domain_error
: public logic_error
{
59 inline explicit domain_error (const char* arg
) throw() : logic_error (arg
) {}
60 inline virtual const char* what (void) const throw() { return ("domain error"); }
63 /// \class invalid_argument ustdxept.h ustl.h
64 /// \ingroup Exceptions
66 /// \brief Reports an invalid argument to a function.
68 class invalid_argument
: public logic_error
{
70 inline explicit invalid_argument (const char* arg
) throw() : logic_error (arg
) {}
71 inline virtual const char* what (void) const throw() { return ("invalid argument"); }
74 /// \class length_error ustdxept.h ustl.h
75 /// \ingroup Exceptions
77 /// \brief Reports when an object exceeds its allowed size.
79 class length_error
: public logic_error
{
81 inline explicit length_error (const char* arg
) throw() : logic_error (arg
) {}
82 inline virtual const char* what (void) const throw() { return ("length error"); }
85 /// \class out_of_range ustdxept.h ustl.h
86 /// \ingroup Exceptions
88 /// \brief Reports arguments with values out of allowed range.
90 class out_of_range
: public logic_error
{
92 inline explicit out_of_range (const char* arg
) throw() : logic_error (arg
) {}
93 inline virtual const char* what (void) const throw() { return ("out of range"); }
96 /// \class runtime_error ustdxept.h ustl.h
97 /// \ingroup Exceptions
99 /// \brief Reports errors that are dependent on the data being processed.
101 class runtime_error
: public error_message
{
103 inline explicit runtime_error (const char* arg
) throw() : error_message (arg
) {}
104 inline virtual const char* what (void) const throw() { return ("runtime error"); }
107 /// \class range_error ustdxept.h ustl.h
108 /// \ingroup Exceptions
110 /// \brief Reports data that does not fall within the permitted range.
112 class range_error
: public runtime_error
{
114 inline explicit range_error (const char* arg
) throw() : runtime_error (arg
) {}
115 inline virtual const char* what (void) const throw() { return ("range error"); }
118 /// \class overflow_error ustdxept.h ustl.h
119 /// \ingroup Exceptions
121 /// \brief Reports arithmetic overflow.
123 class overflow_error
: public runtime_error
{
125 inline explicit overflow_error (const char* arg
) throw() : runtime_error (arg
) {}
126 inline virtual const char* what (void) const throw() { return ("overflow error"); }
129 /// \class underflow_error ustdxept.h ustl.h
130 /// \ingroup Exceptions
132 /// \brief Reports arithmetic underflow.
134 class underflow_error
: public runtime_error
{
136 inline explicit underflow_error (const char* arg
) throw() : runtime_error (arg
) {}
137 inline virtual const char* what (void) const throw() { return ("underflow error"); }