Itasca C++ Interface
Toggle main menu visibility
Loading...
Searching...
No Matches
baseexception.h
1
#pragma once
2
3
#include "istring.h"
4
9
10
class
Exception :
public
std::exception {
11
public
:
12
template
<
typename
FirstArg,
typename
... Args>
13
Exception(
const
IString
&s,
const
FirstArg &fa,Args&&... args) { message_ = fmt::format(convertPercentToBracket((s)), fa, args...); }
14
Exception(
const
IString
&s) : message_(s) { }
15
Exception(
IString
&&s) : message_(std::move(s)) {}
16
Exception(
const
Exception &e) : message_(e.message_) { }
17
Exception(Exception &&e) : message_(std::move(e.message_)) { }
18
Exception &operator=(
const
Exception &e) { message_ = e.message_;
return
*
this
; }
19
Exception &operator=(Exception &&e) { message_ = std::move(e.message_);
return
*
this
; }
20
22
BASE_EXPORT
const
char
*
what
()
const
throw()
override
{
return
message_.c_str(); }
23
25
void
setMessage
(
const
IString
&s) { message_ = s; }
26
27
private
:
28
string
message_;
29
};
30
32
class
QuitException :
public
Exception {
33
public
:
34
BASE_EXPORT
QuitException() : Exception(
"quit"
) { }
35
};
36
38
class
InterruptException
:
public
Exception {
39
public
:
43
BASE_EXPORT
InterruptException
(
bool
safe,
const
IString
&
state
=
IString
())
44
: Exception(
"Processing interrupted by user."
), safe_(safe), state_(
state
) { }
45
47
BASE_EXPORT
bool
wasSafe
()
const
{
return
safe_; }
52
BASE_EXPORT
IString
state
()
const
{
return
state_; }
53
private
:
54
bool
safe_;
55
IString
state_;
56
};
57
58
// EoF
Exception::what
BASE_EXPORT const char * what() const override
Returns the contents of the error message as a const char.
Definition
baseexception.h:22
Exception::setMessage
void setMessage(const IString &s)
Allows the message carried by the exception to be replaced with a new one.
Definition
baseexception.h:25
IString
Definition
istring.h:14
InterruptException::state
BASE_EXPORT IString state() const
Definition
baseexception.h:52
InterruptException::InterruptException
BASE_EXPORT InterruptException(bool safe, const IString &state=IString())
Definition
baseexception.h:43
InterruptException::wasSafe
BASE_EXPORT bool wasSafe() const
returns TRUE if the interrupt was "Safe", in that the model was left in a repeatable and valid state.
Definition
baseexception.h:47
BASE_EXPORT
#define BASE_EXPORT
Definition
basedef.h:24
common
base
src
baseexception.h
Generated by
1.18.0