teqp
0.23.1
Toggle main menu visibility
Loading...
Searching...
No Matches
include
teqp
exceptions.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <exception>
4
5
namespace
teqp
{
6
7
class
teqpcException
:
public
std::exception {
8
public
:
9
const
int
code
;
10
const
std::string
msg
;
11
teqpcException
(
int
code
,
const
std::string&
msg
) :
code
(
code
),
msg
(
msg
) {};
12
const
char
*
what
() const noexcept
override
{
13
return
msg
.c_str();
14
}
15
};
16
17
class
teqpException
:
public
std::exception {
18
protected
:
19
const
int
code
;
20
const
std::string
msg
;
21
teqpException
(
int
code
,
const
std::string&
msg
) :
code
(
code
),
msg
(
msg
) {};
22
public
:
23
const
char
*
what
() const noexcept
override
{
24
return
msg
.c_str();
25
}
26
};
27
28
// Exceptions related to arguments
29
class
InvalidArgument
:
public
teqpException
{
30
public
:
31
InvalidArgument
(
const
std::string&
msg
) :
teqpException
(1,
msg
) {};
32
};
33
34
// Exceptions related to calculations
35
class
IterationFailure
:
public
teqpException
{
36
public
:
37
IterationFailure
(
const
std::string&
msg
) :
teqpException
(100,
msg
) {};
38
};
39
using
IterationError
=
IterationFailure
;
40
class
InvalidValue
:
public
teqpException
{
41
public
:
42
InvalidValue
(
const
std::string&
msg
) :
teqpException
(101,
msg
) {};
43
};
44
45
class
NotImplementedError
:
public
teqpException
{
46
public
:
47
NotImplementedError
(
const
std::string&
msg
) :
teqpException
(200,
msg
) {};
48
};
49
51
class
JSONValidationError
:
public
teqpException
{
52
private
:
53
auto
errors_to_string(
const
std::vector<std::string> &errors,
const
std::string delim =
"|/|\\|"
){
54
std::string o =
""
;
55
if
(errors.empty()){
return
o; }
56
o = errors[0];
57
for
(
auto
j = 1U; j < errors.size(); ++j){
58
o += delim + errors[j];
59
}
60
return
o;
61
}
62
public
:
63
JSONValidationError
(
const
std::vector<std::string>& errors) :
teqpException
(300, errors_to_string(errors)) {};
64
};
65
66
};
// namespace teqp
teqp::InvalidArgument::InvalidArgument
InvalidArgument(const std::string &msg)
Definition
exceptions.hpp:31
teqp::InvalidValue::InvalidValue
InvalidValue(const std::string &msg)
Definition
exceptions.hpp:42
teqp::IterationFailure
Definition
exceptions.hpp:35
teqp::IterationFailure::IterationFailure
IterationFailure(const std::string &msg)
Definition
exceptions.hpp:37
teqp::JSONValidationError::JSONValidationError
JSONValidationError(const std::vector< std::string > &errors)
Definition
exceptions.hpp:63
teqp::NotImplementedError::NotImplementedError
NotImplementedError(const std::string &msg)
Definition
exceptions.hpp:47
teqp::teqpException::msg
const std::string msg
Definition
exceptions.hpp:20
teqp::teqpException::what
const char * what() const noexcept override
Definition
exceptions.hpp:23
teqp::teqpException::teqpException
teqpException(int code, const std::string &msg)
Definition
exceptions.hpp:21
teqp::teqpException::code
const int code
Definition
exceptions.hpp:19
teqp::teqpcException::msg
const std::string msg
Definition
exceptions.hpp:10
teqp::teqpcException::what
const char * what() const noexcept override
Definition
exceptions.hpp:12
teqp::teqpcException::code
const int code
Definition
exceptions.hpp:9
teqp::teqpcException::teqpcException
teqpcException(int code, const std::string &msg)
Definition
exceptions.hpp:11
teqp
Definition
ancillary_builder.hpp:8
teqp::IterationError
IterationFailure IterationError
Definition
exceptions.hpp:39
Generated by
1.17.0