Unnamed Fossil Project

Check-in [e9c0f864af]
Login

Check-in [e9c0f864af]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fatal handling.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e9c0f864af66a5aa5e1186faaaaa2a07d81119f3
User & Date: Spravce 2013-03-30 13:47:34.531
Context
2013-04-06
14:38
Serializace. check-in: 957d8787c3 user: Spravce tags: trunk
2013-03-30
13:47
Fatal handling. check-in: e9c0f864af user: Spravce tags: trunk
2012-12-24
21:24
serializace check-in: a8ad69229f user: Spravce tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to brickyard.html.
219
220
221
222
223
224
225

226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242














243
244
245
246
247
248
249
250
251
252
253
254
255
256
257

258
259
260
261
262
263
264


<p>Compose this message and show it to user.</p>


<pre id="bluescreen" title="bluescreen">
$out=&quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;error&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;:-(&lt;/h1&gt;&quot;;

$out.=&quot;&lt;div&gt;&quot; . nl2br( $e-&gt;getMessage() ) . &quot;&lt;/div&gt;&quot;;
$out.=&quot;&lt;pre&gt;&quot; . $e-&gt;getTraceAsString() . &quot;&lt;/pre&gt;&quot;;
$out.=&quot;&lt;/body&gt;&lt;/html&gt;&quot;;
echo $out;
exit;
</pre>


<h3>Error handling</h3>

<p>This is simple rethrowing to ErrorException.</p>


<pre id="error handling" title="error handling">
throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
</pre>
















<h3>Init function</h3>

<p>We register autoload.</p>


<pre id="init" title="init">
spl_autoload_register(array($this,&quot;autoload&quot;));
</pre>


<p>Error handling.</p>

<pre id="init" title="init">
set_error_handler(array($this,&quot;error_handler&quot;));

</pre>


<p>And exception handling.</p>


<pre id="init" title="init">







>

















>
>
>
>
>
>
>
>
>
>
>
>
>
>















>







219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280


<p>Compose this message and show it to user.</p>


<pre id="bluescreen" title="bluescreen">
$out=&quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;error&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;:-(&lt;/h1&gt;&quot;;
$out.=&quot;&lt;div&gt;at &quot; . $e-&gt;getFile() . ':' . $e-&gt;getLine() . &quot;&lt;/div&gt;&quot;;
$out.=&quot;&lt;div&gt;&quot; . nl2br( $e-&gt;getMessage() ) . &quot;&lt;/div&gt;&quot;;
$out.=&quot;&lt;pre&gt;&quot; . $e-&gt;getTraceAsString() . &quot;&lt;/pre&gt;&quot;;
$out.=&quot;&lt;/body&gt;&lt;/html&gt;&quot;;
echo $out;
exit;
</pre>


<h3>Error handling</h3>

<p>This is simple rethrowing to ErrorException.</p>


<pre id="error handling" title="error handling">
throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
</pre>


<h3>Fatal handling</h3>

<p>Fatals are errors too.</p>


<pre id="fatal handling" title="fatal handling">
$error = error_get_last();
if ($error['type'] &amp; (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_PARSE)) {
    $fatal = new ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']);
    $this-&gt;exception_handler($fatal);
}
</pre>


<h3>Init function</h3>

<p>We register autoload.</p>


<pre id="init" title="init">
spl_autoload_register(array($this,&quot;autoload&quot;));
</pre>


<p>Error handling.</p>

<pre id="init" title="init">
set_error_handler(array($this,&quot;error_handler&quot;));
register_shutdown_function(array($this, &quot;shutdown_handler&quot;));
</pre>


<p>And exception handling.</p>


<pre id="init" title="init">
396
397
398
399
400
401
402





403
404
405
406
407
408
409
        &lt;&lt;error handling&gt;&gt;
    }

    public function exception_handler($e)
    {
        &lt;&lt;exception handling&gt;&gt;
    }






    public function bluescreen($e)
    {
        &lt;&lt;bluescreen&gt;&gt;
    }

    public function init(){







>
>
>
>
>







412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
        &lt;&lt;error handling&gt;&gt;
    }

    public function exception_handler($e)
    {
        &lt;&lt;exception handling&gt;&gt;
    }

    public function shutdown_handler()
    {
        &lt;&lt;fatal handling&gt;&gt;
    }

    public function bluescreen($e)
    {
        &lt;&lt;bluescreen&gt;&gt;
    }

    public function init(){
Changes to brickyard.nw.
171
172
173
174
175
176
177

178
179
180
181
182
183
184
185
186
187
188
189
190
191












192
193
194
195
196
197
198
199
200
201
202
203

204
205
206
207
208
209
210
ob_clean();
@

Compose this message and show it to user.

<<bluescreen>>==
$out="<html><head><title>error</title></head><body><h1>:-(</h1>";

$out.="<div>" . nl2br( $e->getMessage() ) . "</div>";
$out.="<pre>" . $e->getTraceAsString() . "</pre>";
$out.="</body></html>";
echo $out;
exit;
@

###Error handling

This is simple rethrowing to ErrorException.

<<error handling>>==
throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
@













###Init function

We register autoload.

<<init>>==
spl_autoload_register(array($this,"autoload"));
@

Error handling.
<<init>>==
set_error_handler(array($this,"error_handler"));

@

And exception handling.

<<init>>==
set_exception_handler(array($this,"exception_handler"));
@







>














>
>
>
>
>
>
>
>
>
>
>
>












>







171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
ob_clean();
@

Compose this message and show it to user.

<<bluescreen>>==
$out="<html><head><title>error</title></head><body><h1>:-(</h1>";
$out.="<div>at " . $e->getFile() . ':' . $e->getLine() . "</div>";
$out.="<div>" . nl2br( $e->getMessage() ) . "</div>";
$out.="<pre>" . $e->getTraceAsString() . "</pre>";
$out.="</body></html>";
echo $out;
exit;
@

###Error handling

This is simple rethrowing to ErrorException.

<<error handling>>==
throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
@

###Fatal handling

Fatals are errors too.

<<fatal handling>>==
$error = error_get_last();
if ($error['type'] & (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_PARSE)) {
	$fatal = new ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']);
	$this->exception_handler($fatal);
}
@

###Init function

We register autoload.

<<init>>==
spl_autoload_register(array($this,"autoload"));
@

Error handling.
<<init>>==
set_error_handler(array($this,"error_handler"));
register_shutdown_function(array($this, "shutdown_handler"));
@

And exception handling.

<<init>>==
set_exception_handler(array($this,"exception_handler"));
@
318
319
320
321
322
323
324





325
326
327
328
329
330
331
		<<error handling>>
	}
	
	public function exception_handler($e)
	{
		<<exception handling>>
	}





	
	public function bluescreen($e)
	{
		<<bluescreen>>
	}
	
	public function init(){







>
>
>
>
>







332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
		<<error handling>>
	}
	
	public function exception_handler($e)
	{
		<<exception handling>>
	}
	
	public function shutdown_handler()
	{
		<<fatal handling>>
	}
	
	public function bluescreen($e)
	{
		<<bluescreen>>
	}
	
	public function init(){
Changes to brickyard.php.
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
			}else{
				echo "An error occured. Also error page is missing.";
			}
			
		}
		
	}










	
	public function bluescreen($e)
	{
		ob_clean();
		$out="<html><head><title>error</title></head><body><h1>:-(</h1>";

		$out.="<div>" . nl2br( $e->getMessage() ) . "</div>";
		$out.="<pre>" . $e->getTraceAsString() . "</pre>";
		$out.="</body></html>";
		echo $out;
		exit;
		
	}
	
	public function init(){
		spl_autoload_register(array($this,"autoload"));
		set_error_handler(array($this,"error_handler"));

		set_exception_handler(array($this,"exception_handler"));
		
	}
	
	public function run(){
		ob_start();
		$controllerName = "c_" . $this->router->getController();







>
>
>
>
>
>
>
>
>
>





>











>







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
			}else{
				echo "An error occured. Also error page is missing.";
			}
			
		}
		
	}
	
	public function shutdown_handler()
	{
		$error = error_get_last();
		if ($error['type'] & (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_PARSE)) {
			$fatal = new ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']);
			$this->exception_handler($fatal);
		}
		
	}
	
	public function bluescreen($e)
	{
		ob_clean();
		$out="<html><head><title>error</title></head><body><h1>:-(</h1>";
		$out.="<div>at " . $e->getFile() . ':' . $e->getLine() . "</div>";
		$out.="<div>" . nl2br( $e->getMessage() ) . "</div>";
		$out.="<pre>" . $e->getTraceAsString() . "</pre>";
		$out.="</body></html>";
		echo $out;
		exit;
		
	}
	
	public function init(){
		spl_autoload_register(array($this,"autoload"));
		set_error_handler(array($this,"error_handler"));
		register_shutdown_function(array($this, "shutdown_handler"));
		set_exception_handler(array($this,"exception_handler"));
		
	}
	
	public function run(){
		ob_start();
		$controllerName = "c_" . $this->router->getController();
Added c/fatal.php.












>
>
>
>
>
>
1
2
3
4
5
6
<?php
class c_fatal
{
	function index()
	{
}