-
-
Notifications
You must be signed in to change notification settings - Fork 467
/
exceptions.zep
142 lines (120 loc) · 2.29 KB
/
exceptions.zep
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
namespace Stub;
class Exceptions
{
public internalExceptionCallable;
public exceptionCallable;
public function testException1()
{
throw new Exception("hello1");
}
public function testExceptionStringEscape()
{
throw new Exception("hello \"simple code\" test");
}
public function testException2()
{
var msg;
let msg = "hello2";
throw new Exception(msg);
}
public function testException3()
{
var ex, msg;
let msg = "hello3";
let ex = new Exception(msg);
throw ex;
}
protected function getException()
{
return new Exception("hello4");
}
public function testException4()
{
throw this->getException();
}
public function testException5()
{
var exception;
let exception = new Exception("hello5");
throw exception;
}
public function testExceptionLiteral(string type)
{
switch(type) {
case "string":
throw "Test";
case "char":
throw 't';
case "int":
throw 123;
case "double":
throw 123.123;
}
}
public function testExceptionSprintf(string name)
{
throw sprintf("Hello, %s", name);
}
public function testExceptionConcat(string framework, string language)
{
throw "Framework " . framework . " written using " . language;
}
public function testExceptionRethrow()
{
var e;
try {
this->testException1();
}
catch \Exception, e {
throw e;
}
}
public function testMultiException(var returnValue, var exception)
{
var e, f, iexc, exc;
let iexc = this->internalExceptionCallable;
let exc = this->exceptionCallable;
try {
throw exception;
}
catch Exception, e {
if is_callable(iexc) && {iexc}() === false {
}
else {
throw e;
}
}
catch \Exception, e {
if is_callable(exc) && {exc}() === false {
}
else {
throw e;
}
}
catch \RuntimeError | \LogicError, f {
if is_callable(exc) && {exc}() === false {
}
else {
throw f;
}
}
return returnValue;
}
public function issue1325()
{
var e, status;
try {
let status = this->doNoopException();
}
catch \Exception, e {
// Throws fatal variable is already observed. Note, the above call must be a
// method that assigns to variable in order for exception to occur.
let status = "woop";
}
return 1;
}
private function doNoopException()
{
throw new \Exception("I am exception");
}
}