-
Notifications
You must be signed in to change notification settings - Fork 5
/
error.h
103 lines (84 loc) · 2.18 KB
/
error.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef __mpw_error_h__
#define __mpw_error_h__
#include <stdexcept>
#include <system_error>
class mpw_error : public std::runtime_error {
public:
mpw_error(int status, const std::string &s) : std::runtime_error(s), _status(status)
{}
mpw_error(int status, const char *s) : std::runtime_error(s), _status(status)
{}
int status() const noexcept { return _status; }
private:
int _status;
};
class execution_of_input_terminated : public mpw_error {
public:
execution_of_input_terminated(int status = -9) :
mpw_error(status, "MPW Shell - Execution of input Terminated.")
{}
};
class break_error : public mpw_error {
public:
break_error(int status = -3) :
mpw_error(status, "MPW Shell - Break must be within for or loop.")
{}
};
class continue_error : public mpw_error {
public:
continue_error(int status = -3) :
mpw_error(status, "MPW Shell - Continue must be within for or loop.")
{}
};
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.")
{}
};
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.")
{}
};
class fsstring_error: public mpw_error {
public:
fsstring_error(int status = -3) :
mpw_error(status, "MPW Shell - /s must occur in pairs.")
{}
};
class bsstring_error: public mpw_error {
public:
bsstring_error(int status = -3) :
mpw_error(status, "MPW Shell - \\s must occur in pairs.")
{}
};
class regex_error : public mpw_error {
public:
regex_error(int status = -2) :
mpw_error(status, "MPW Shell - File name pattern is incorrect")
{}
};
/*
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 {};
#endif