Calculator Step 4

- Main Page
- Classes
- Files

- File List
- File Members

calc_error.hpp
Go to the documentation of this file.
1 #ifndef CALC_ERROR_HPP_
2 #define CALC_ERROR_HPP_
3
4 #include <cstdlib>
5 #include <stdexcept>
6 #include <string>
7
14 class calc_error : public std::runtime_error
15 {
16 public:
17 calc_error(std::string const& msg) : runtime_error{msg} {}
18 };
19
21 class parse_error : public calc_error {
22 public:
23 parse_error(std::string const& msg) : calc_error{msg} {}
24 };
25
27 class syntax_error : public parse_error {
28 public:
29 syntax_error(std::string const& msg) : parse_error{"syntax error: " + msg} {}
30 };
31
34 class function_error : public calc_error
35 {
36 public:
37 function_error(std::string const &name, std::size_t expected, std::size_t actual)
38 : calc_error{msg(name, expected, actual)}
39 {}
40 private:
41 std::string msg(std::string const& name, std::size_t expected, std::size_t actual);
42 };
43
45 class no_such_function : public calc_error {
46 public:
47 no_such_function(std::string const& what) : calc_error{"unknown function: " + what} {}
48 };
49
50 #endif
calc_error
Definition: calc_error.hpp:14
no_such_function::no_such_function
no_such_function(std::string const &what)
Definition: calc_error.hpp:47
parse_error::parse_error
parse_error(std::string const &msg)
Definition: calc_error.hpp:23
syntax_error
Definition: calc_error.hpp:27
parse_error
Definition: calc_error.hpp:21
function_error::function_error
function_error(std::string const &name, std::size_t expected, std::size_t actual)
Definition: calc_error.hpp:37
function_error
Definition: calc_error.hpp:34
calc_error::calc_error
calc_error(std::string const &msg)
Definition: calc_error.hpp:17
no_such_function
Definition: calc_error.hpp:45
syntax_error::syntax_error
syntax_error(std::string const &msg)
Definition: calc_error.hpp:29
function_error::msg
std::string msg(std::string const &name, std::size_t expected, std::size_t actual)
Definition: calc_error.cpp:5