28#ifndef _util_misc_scexception_h
29#define _util_misc_scexception_h
32#include <util/misc/exception.h>
35#include <util/class/class.h>
36#include <util/misc/bug.h>
45 const char *exception_type_;
46 mutable char *elaboration_c_str_;
47 std::ostringstream *elaboration_;
73 const
char*
what() const MPQC__NOEXCEPT;
79 const char *
exception_type() const MPQC__NOEXCEPT {
return exception_type_; }
109 const char *
file = 0,
137 const char *
file = 0,
154 const char *keyword_;
174 const char *
file = 0,
176 const char *keyword = 0,
177 const char *value = 0,
183 const
char *keyword() const MPQC__NOEXCEPT {
return keyword_; }
186 const char *
value() const MPQC__NOEXCEPT {
return value_; }
211 const char *file = 0,
214 const char *exception_type =
"SystemException") MPQC__NOEXCEPT;
240 const char *file = 0,
244 const char *exception_type =
"MemAllocFailed") MPQC__NOEXCEPT;
249 size_t nbyte() const MPQC__NOEXCEPT {
return nbyte_; }
256 enum FileOperation { Unknown, OpenR, OpenW, OpenRW,
257 Close, Read, Write, Corrupt, Other };
260 const char *filename_;
261 FileOperation operation_;
281 const char *source_file = 0,
283 const char *filename = 0,
284 FileOperation operation = Unknown,
286 const char *exception_type =
"FileOperationFailed") MPQC__NOEXCEPT;
292 const
char * filename() const MPQC__NOEXCEPT {
return filename_; }
294 FileOperation
operation() const MPQC__NOEXCEPT {
return operation_; }
300 const char *syscall_;
320 const char *source_file = 0,
322 const char *syscall = 0,
325 const char *exception_type =
"SyscallFailed") MPQC__NOEXCEPT;
331 const
char * syscall() const MPQC__NOEXCEPT {
return syscall_; }
333 int err() const MPQC__NOEXCEPT {
return err_; }
359 const char *file = 0,
362 const char *exception_type =
"AlgorithmException")
390 const char *file = 0,
394 const char *exception_type =
"MaxIterExceeded") MPQC__NOEXCEPT;
399 int max_iter() const MPQC__NOEXCEPT {
return max_iter_; }
425 const char *file = 0,
430 const char *exception_type =
"ToleranceExceeded") MPQC__NOEXCEPT;
434 double tolerance() MPQC__NOEXCEPT {
return tolerance_; }
436 double value() MPQC__NOEXCEPT {
return value_; }
473 const char *exception_type = strdup((std::string(
"LimitExceeded<") + std::string(
typeid(T).name()) + std::string(
">")).c_str())
475 SCException(description, file, line, class_desc, exception_type),
476 limit_(lim), value_(val)
479 elaborate() <<
"value: " << value_
481 <<
"limit: " << limit_
489 limit_(ref.limit_), value_(ref.value_)
492 ~LimitExceeded() MPQC__NOEXCEPT {}
496 T
value() MPQC__NOEXCEPT {
return value_; }
504 const char* assertion_text_;
520 int line) MPQC__NOEXCEPT;
522 const char* assertion_text() const MPQC__NOEXCEPT {
return assertion_text_; }
563#define __scexception_h_finished
This exception is thrown whenever a problem with an algorithm is encountered.
Definition scexception.h:342
AlgorithmException(const char *description=0, const char *file=0, int line=0, const ClassDesc *class_desc=0, const char *exception_type="AlgorithmException") MPQC__NOEXCEPT
Create an AlgorithmException.
This is thrown when an assertion fails.
Definition scexception.h:502
AssertionFailed(const char *assertion_text, const char *file, int line) MPQC__NOEXCEPT
Create an AssertionFailed exception.
This class is used to contain information about classes.
Definition class.h:147
Creates a backtrace of a running program/thread.
Definition bug.h:123
This is a std::exception specialization that records information about where an exception took place.
Definition exception.h:48
const char * file() const MPQC__NOEXCEPT
Returns the name of the file in which the exception was created.
Definition exception.h:78
int line() const MPQC__NOEXCEPT
Returns the line number where the exception was created.
Definition exception.h:81
const char * description() const MPQC__NOEXCEPT
Reimplementation of std::exception::what().
Definition exception.h:75
This is thrown when an attempt is made to use a feature that is not yet implemented.
Definition scexception.h:120
FeatureNotImplemented(const char *description=0, const char *file=0, int line=0, const ClassDesc *class_desc=0, const char *exception_type="FeatureNotImplemented") MPQC__NOEXCEPT
Create a FeatureNotImplemented exception.
This is thrown when an operation on a file fails.
Definition scexception.h:254
FileOperation operation() const MPQC__NOEXCEPT
Return the file operation that failed as a FileOperation enum.
Definition scexception.h:294
FileOperationFailed(const char *description=0, const char *source_file=0, int line=0, const char *filename=0, FileOperation operation=Unknown, const ClassDesc *class_desc=0, const char *exception_type="FileOperationFailed") MPQC__NOEXCEPT
Create a FileOperationFailure exception.
This is thrown when a limit is exceeded.
Definition scexception.h:447
LimitExceeded(const char *description, const char *file, int line, T lim, T val, const ClassDesc *class_desc=0, const char *exception_type=strdup((std::string("LimitExceeded<")+std::string(typeid(T).name())+std::string(">")).c_str())) MPQC__NOEXCEPT
Create a LimitExceeded exception.
Definition scexception.h:467
T value() MPQC__NOEXCEPT
The value which exceeded the limit.
Definition scexception.h:496
T tolerance() MPQC__NOEXCEPT
The limit which was exceeded.
Definition scexception.h:494
This is thrown when an iterative algorithm attempts to use more iterations than allowed.
Definition scexception.h:371
MaxIterExceeded(const char *description=0, const char *file=0, int line=0, int maxiter=0, const ClassDesc *class_desc=0, const char *exception_type="MaxIterExceeded") MPQC__NOEXCEPT
Create a MaxIterExceeded exception.
This is thrown when a memory allocation fails.
Definition scexception.h:221
MemAllocFailed(const char *description=0, const char *file=0, int line=0, size_t nbyte=0, const ClassDesc *class_desc=0, const char *exception_type="MemAllocFailed") MPQC__NOEXCEPT
Create a MemAllocFailed exception.
This is thrown when a situations arises that should be impossible.
Definition scexception.h:92
ProgrammingError(const char *description=0, const char *file=0, int line=0, const ClassDesc *class_desc=0, const char *exception_type="ProgrammingError") MPQC__NOEXCEPT
Create a ProgrammingError exception.
This is a sc::Exception specialization that keeps track of the ClassDesc for the MPQC object from whi...
Definition scexception.h:43
std::ostream & elaborate()
Returns a stream where additional information about the exception can be written.
const char * what() const MPQC__NOEXCEPT
overload of Exception::what()
SCException(const char *description=0, const char *file=0, int line=0, const ClassDesc *class_desc=0, const char *exception_type="SCException") MPQC__NOEXCEPT
Create an SCException.
const ClassDesc * class_desc() const MPQC__NOEXCEPT
Returns the class descriptor of the object which generated the exception.
Definition scexception.h:77
const char * exception_type() const MPQC__NOEXCEPT
Returns the classname of the exception. May return null.
Definition scexception.h:79
This is thrown when an system call fails with an errno.
Definition scexception.h:299
int err() const MPQC__NOEXCEPT
Return the error code that the system call returned.
Definition scexception.h:333
SyscallFailed(const char *description=0, const char *source_file=0, int line=0, const char *syscall=0, int err=0, const ClassDesc *class_desc=0, const char *exception_type="SyscallFailed") MPQC__NOEXCEPT
Create a SyscallFailed exception.
This is thrown when a system problem occurs.
Definition scexception.h:194
SystemException(const char *description=0, const char *file=0, int line=0, const ClassDesc *class_desc=0, const char *exception_type="SystemException") MPQC__NOEXCEPT
Create a SystemException exception.
This is thrown when when some tolerance is exceeded.
Definition scexception.h:404
ToleranceExceeded(const char *description=0, const char *file=0, int line=0, double tol=0, double val=0, const ClassDesc *class_desc=0, const char *exception_type="ToleranceExceeded") MPQC__NOEXCEPT
Create a ToleranceExceeded exception.
double value() MPQC__NOEXCEPT
Return the value which was obtained.
Definition scexception.h:436
Contains all MPQC code up to version 3.
Definition mpqcin.h:14