2016-02-02 21:19:13 +00:00
|
|
|
#ifndef __mpw_error_h__
|
|
|
|
#define __mpw_error_h__
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <system_error>
|
|
|
|
|
2016-06-16 03:01:03 +00:00
|
|
|
class mpw_error : public std::runtime_error {
|
2016-02-02 21:19:13 +00:00
|
|
|
public:
|
2016-06-16 03:01:03 +00:00
|
|
|
mpw_error(int status, const std::string &s) : std::runtime_error(s), _status(status)
|
2016-02-02 21:19:13 +00:00
|
|
|
{}
|
2016-06-16 03:01:03 +00:00
|
|
|
|
|
|
|
mpw_error(int status, const char *s) : std::runtime_error(s), _status(status)
|
|
|
|
{}
|
|
|
|
|
2016-08-06 02:00:48 +00:00
|
|
|
int status() const noexcept { return _status; }
|
2016-02-02 21:19:13 +00:00
|
|
|
private:
|
2016-07-27 18:04:57 +00:00
|
|
|
int _status;
|
2016-06-16 03:01:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class execution_of_input_terminated : public mpw_error {
|
|
|
|
public:
|
|
|
|
execution_of_input_terminated(int status = -9) :
|
2016-07-27 18:04:57 +00:00
|
|
|
mpw_error(status, "MPW Shell - Execution of input Terminated.")
|
2016-06-16 03:01:03 +00:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class break_error : public mpw_error {
|
|
|
|
public:
|
|
|
|
break_error(int status = -3) :
|
|
|
|
mpw_error(status, "MPW Shell - Break must be within for or loop.")
|
|
|
|
{}
|
2016-02-02 21:19:13 +00:00
|
|
|
};
|
|
|
|
|
2016-06-16 03:01:03 +00:00
|
|
|
class continue_error : public mpw_error {
|
|
|
|
public:
|
|
|
|
continue_error(int status = -3) :
|
|
|
|
mpw_error(status, "MPW Shell - Continue must be within for or loop.")
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2016-07-27 18:04:57 +00:00
|
|
|
class estring_error: public mpw_error {
|
|
|
|
public:
|
|
|
|
estring_error(int status = -3) :
|
|
|
|
mpw_error(status, "MPW Shell - `s must occur in pairs.")
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
class vstring_error: public mpw_error {
|
|
|
|
public:
|
|
|
|
vstring_error(int status = -3) :
|
|
|
|
mpw_error(status, "MPW Shell - {s must occur in pairs.")
|
|
|
|
{}
|
|
|
|
};
|
2016-06-16 03:01:03 +00:00
|
|
|
|
2016-07-27 18:04:57 +00:00
|
|
|
class sstring_error: public mpw_error {
|
|
|
|
public:
|
|
|
|
sstring_error(int status = -3) :
|
|
|
|
mpw_error(status, "MPW Shell - 's must occur in pairs.")
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
class dstring_error: public mpw_error {
|
|
|
|
public:
|
|
|
|
dstring_error(int status = -3) :
|
|
|
|
mpw_error(status, "MPW Shell - \"s must occur in pairs.")
|
|
|
|
{}
|
|
|
|
};
|
2016-06-16 03:01:03 +00:00
|
|
|
|
2016-08-30 16:25:43 +00:00
|
|
|
/*
|
|
|
|
these are used for flow-control.
|
|
|
|
they do not inherit from std::exception to prevent being caught
|
|
|
|
by normal handlers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct break_command_t {};
|
|
|
|
struct continue_command_t {};
|
|
|
|
struct exit_command_t { int value = 0; };
|
|
|
|
struct quit_command_t {};
|
|
|
|
|
2016-02-02 21:19:13 +00:00
|
|
|
#endif
|