32#ifndef _util_misc_scexception_h
33#define _util_misc_scexception_h
35#ifndef _util_class_class_h
36#include <util/class/class.h>
49class SCException:
public std::exception {
50 const char *description_;
54 const char *exception_type_;
55 std::ostringstream *elaboration_;
58 SCException(
const char *description = 0,
62 const char *exception_type =
"SCException")
throw();
63 SCException(
const SCException&)
throw();
64 ~SCException()
throw();
68 const char*
what()
const throw();
70 const
char *description() const throw() {
return description_; }
71 const char *file()
const throw() {
return file_; }
72 int line()
const throw() {
return line_; }
73 const ClassDesc *class_desc()
const throw() {
return class_desc_; }
74 const char *exception_type()
const throw() {
return exception_type_; }
87class ProgrammingError:
public SCException {
90 ProgrammingError(
const char *description = 0,
94 const char *exception_type =
"ProgrammingError")
throw();
95 ProgrammingError(
const ProgrammingError&)
throw();
96 ~ProgrammingError()
throw();
102class FeatureNotImplemented:
public ProgrammingError {
105 FeatureNotImplemented(
const char *description = 0,
106 const char *file = 0,
109 const char *exception_type =
"FeatureNotImplemented")
111 FeatureNotImplemented(
const FeatureNotImplemented&)
throw();
112 ~FeatureNotImplemented()
throw();
122class InputError:
public SCException {
123 const char *keyword_;
127 InputError(
const char *description = 0,
128 const char *file = 0,
130 const char *keyword = 0,
131 const char *value = 0,
133 const char *exception_type =
"InputError")
throw();
134 InputError(
const InputError&)
throw();
135 ~InputError()
throw();
136 const char *keyword()
const throw() {
return keyword_; }
137 const char *value()
const throw() {
return value_; }
145class SystemException:
public SCException {
148 SystemException(
const char *description = 0,
149 const char *file = 0,
152 const char *exception_type =
"SystemException")
throw();
153 SystemException(
const SystemException&)
throw();
154 ~SystemException()
throw();
159class MemAllocFailed:
public SystemException {
163 MemAllocFailed(
const char *description = 0,
164 const char *file = 0,
168 const char *exception_type =
"MemAllocFailed")
throw();
169 MemAllocFailed(
const MemAllocFailed&)
throw();
170 ~MemAllocFailed()
throw();
173 size_t nbyte()
const throw() {
return nbyte_; }
178class FileOperationFailed:
public SystemException {
180 enum FileOperation { Unknown, OpenR, OpenW, OpenRW,
181 Close, Read, Write, Corrupt, Other };
184 const char *filename_;
185 FileOperation operation_;
188 FileOperationFailed(
const char *description = 0,
189 const char *source_file = 0,
192 FileOperation operation = Unknown,
194 const char *exception_type =
"FileOperationFailed")
throw();
195 FileOperationFailed(
const FileOperationFailed&)
throw();
196 ~FileOperationFailed()
throw();
200 const char *
filename()
const throw() {
return filename_; }
201 FileOperation operation()
const throw() {
return operation_; }
206class SyscallFailed:
public SystemException {
207 const char *syscall_;
211 SyscallFailed(
const char *description = 0,
212 const char *source_file = 0,
217 const char *exception_type =
"SyscallFailed")
throw();
218 SyscallFailed(
const SyscallFailed&)
throw();
219 ~SyscallFailed()
throw();
223 const char *
syscall()
const throw() {
return syscall_; }
224 int err()
const throw() {
return err_; }
233class AlgorithmException:
public SCException {
236 AlgorithmException(
const char *description = 0,
237 const char *file = 0,
240 const char *exception_type =
"AlgorithmException")
242 AlgorithmException(
const AlgorithmException&)
throw();
243 ~AlgorithmException()
throw();
249class MaxIterExceeded:
public AlgorithmException {
253 MaxIterExceeded(
const char *description = 0,
254 const char *file = 0,
258 const char *exception_type =
"MaxIterExceeded")
throw();
259 MaxIterExceeded(
const MaxIterExceeded&)
throw();
260 ~MaxIterExceeded()
throw();
262 int max_iter()
const throw() {
return max_iter_; }
267class ToleranceExceeded:
public AlgorithmException {
272 ToleranceExceeded(
const char *description = 0,
273 const char *file = 0,
278 const char *exception_type =
"ToleranceExceeded")
throw();
279 ToleranceExceeded(
const ToleranceExceeded&)
throw();
280 ~ToleranceExceeded()
throw();
281 double tolerance()
throw() {
return tolerance_; }
282 double value()
throw() {
return value_; }
293class LimitExceeded:
public SCException {
298 LimitExceeded(
const char *description,
304 const char *exception_type =
"LimitExceeded")
throw():
305 SCException(description, file, line, class_desc, exception_type),
306 limit_(lim), value_(val)
311 <<
"limit: " << limit_
317 LimitExceeded(
const LimitExceeded&ref)
throw():
319 limit_(ref.limit_), value_(ref.value_)
322 ~LimitExceeded()
throw() {}
323 T tolerance()
throw() {
return limit_; }
324 T value()
throw() {
return value_; }
This class is used to contain information about classes.
Definition class.h:158
const char * filename() const
Returns the file name of the file that caused the error, if known.
Definition scexception.h:200
size_t nbyte() const
Returns the number of bytes used in the failed allocation attempt.
Definition scexception.h:173
std::ostream & elaborate()
Returns a stream where addition information about the exception can be written.
const char * what() const
Reimplementation of std::exception::what().
const char * syscall() const
Returns the file name of the file that caused the error, if known.
Definition scexception.h:223