throw Error objects instead of alert()ing when errors happen.
Chris Pressey
6 years ago
0 | 0 | /* |
1 | * This file is part of yoob.js version 0.11 | |
1 | * This file is part of yoob.js version 0.12-PRE | |
2 | 2 | * Available from https://github.com/catseye/yoob.js/ |
3 | 3 | * This file is in the public domain. See http://unlicense.org/ for details. |
4 | 4 | */ |
196 | 196 | * - `block` to indicate that the program is waiting for more input. |
197 | 197 | */ |
198 | 198 | this.step = function() { |
199 | alert("step() NotImplementedError"); | |
199 | throw new Error("step() NotImplementedError"); | |
200 | 200 | }; |
201 | 201 | |
202 | 202 | /****************** |
265 | 265 | }; |
266 | 266 | |
267 | 267 | this.reset = function(state) { |
268 | alert("reset() NotImplementedError"); | |
268 | throw new Error("reset() NotImplementedError"); | |
269 | 269 | }; |
270 | 270 | |
271 | 271 | this.setResetState = function(state) { |
0 | 0 | /* |
1 | * This file is part of yoob.js version 0.11 | |
1 | * This file is part of yoob.js version 0.12-PRE | |
2 | 2 | * Available from https://github.com/catseye/yoob.js/ |
3 | 3 | * This file is in the public domain. See http://unlicense.org/ for details. |
4 | 4 | */ |
132 | 132 | this.put(x, y, this.get(x, y - dy)); |
133 | 133 | } |
134 | 134 | } |
135 | } else { alert("scrollRectangleY(" + dy + ") notImplemented"); } | |
135 | } else { | |
136 | throw new Error("scrollRectangleY(" + dy + ") notImplemented"); | |
137 | } | |
136 | 138 | }; |
137 | 139 | |
138 | 140 | this.clearRectangle = function(minX, minY, maxX, maxY) { |
0 | 0 | /* |
1 | * This file is part of yoob.js version 0.8 | |
1 | * This file is part of yoob.js version 0.12-PRE | |
2 | 2 | * Available from https://github.com/catseye/yoob.js/ |
3 | 3 | * This file is in the public domain. See http://unlicense.org/ for details. |
4 | 4 | */ |
67 | 67 | }; |
68 | 68 | |
69 | 69 | this.setPreset = function(id) { |
70 | alert("No default setPreset callback configured"); | |
70 | throw new Error("No default setPreset callback configured"); | |
71 | 71 | }; |
72 | 72 | |
73 | 73 | /* |
0 | 0 | /* |
1 | * This file is part of yoob.js version 0.7 | |
1 | * This file is part of yoob.js version 0.12-PRE | |
2 | 2 | * Available from https://github.com/catseye/yoob.js/ |
3 | 3 | * This file is in the public domain. See http://unlicense.org/ for details. |
4 | 4 | */ |
18 | 18 | if (this.state[nm].init) { |
19 | 19 | this.state[nm].init(); |
20 | 20 | } else { |
21 | alert('Internal error: "' + nm + '" must implement .init'); | |
21 | throw new Error('"' + nm + '" must implement .init'); | |
22 | 22 | } |
23 | 23 | } |
24 | 24 | return this; |
33 | 33 | if (this.currentState.onleave) { |
34 | 34 | this.currentState.onleave(); |
35 | 35 | } else { |
36 | alert('Internal error: "' + nm + '" must implement .onleave'); | |
36 | throw new Error('"' + nm + '" must implement .onleave'); | |
37 | 37 | } |
38 | 38 | } |
39 | 39 | var state = this.state[nm]; |
41 | 41 | if (state.onenter) { |
42 | 42 | state.onenter(args); |
43 | 43 | } else { |
44 | alert('Internal error: "' + nm + '" must implement .onenter'); | |
44 | throw new Error('"' + nm + '" must implement .onenter'); | |
45 | 45 | } |
46 | 46 | return this; |
47 | 47 | }; |
52 | 52 | */ |
53 | 53 | yoob.State = function() { |
54 | 54 | this.init = function() { |
55 | alert("You must implement .init()"); | |
55 | throw new Error("You must implement .init()"); | |
56 | 56 | }; |
57 | 57 | |
58 | 58 | /* |
65 | 65 | * should only do so as the last thing in the handler. |
66 | 66 | */ |
67 | 67 | this.onenter = function(args) { |
68 | alert("You must implement .onenter()"); | |
68 | throw new Error("You must implement .onenter()"); | |
69 | 69 | }; |
70 | 70 | |
71 | 71 | /* |
75 | 75 | * Cancel timers/animations |
76 | 76 | */ |
77 | 77 | this.onleave = function() { |
78 | alert("You must implement .onleave()"); | |
78 | throw new Error("You must implement .onleave()"); | |
79 | 79 | }; |
80 | 80 | }; |