calc_error.hpp

Go to the documentation of this file.
00001 #ifndef FUNCTON_ERROR_HPP_
00002 #define FUNCTON_ERROR_HPP_
00003 
00004 #include <cerrno>
00005 #include <cstdlib>
00006 #include <cstring>
00007 #include <stdexcept>
00008 #include <string>
00009 
00011 class calc_error : public std::runtime_error
00012 {
00013 public:
00014   calc_error(std::string const& msg) : runtime_error(msg) {}
00015 };
00016 
00018 class parse_error : public calc_error {
00019 public:
00020   parse_error(std::string const& msg) : calc_error(msg) {}
00021 };
00022 
00024 class syntax_error : public parse_error {
00025 public:
00026   syntax_error(std::string const& msg) : parse_error("syntax error: " + msg) {}
00027 };
00028 
00031 class function_error : public calc_error
00032 {
00033 public:
00034   function_error(std::string const &name, std::size_t expected, std::size_t actual)
00035   : calc_error(msg(name, expected, actual))
00036   {}
00037 private:
00038   std::string msg(std::string const& name, std::size_t expected, std::size_t actual);
00039 };
00040 
00042 class no_such_function : public calc_error {
00043 public:
00044   no_such_function(std::string const& what) : calc_error("unknown function: " + what) {}
00045 };
00046 
00050 class file_error : public calc_error {
00051 public:
00052   file_error(std::string const& filename) : calc_error(filename + ": " + std::strerror(errno)) {}
00053 };
00054 
00055 #endif

Generated on Sun Nov 30 10:06:51 2008 for Calculator by  doxygen 1.5.3