root/trunk/SimpleException.d

Revision 33, 0.9 kB (checked in by xammy, 4 years ago)

Updated to tango version

Line 
1 import  fcgi.Thread;
2 import  fcgi.Connection;
3 import  fcgi.Request;
4 import  fcgi.Exception;
5
6 import  tango.math.random.Kiss;
7
8 Kiss rnd;
9
10 int myrun(FastCGIRequest request)
11 {
12     request.stdout.write ("Content-type: text/html\r\n\r\n");
13
14     switch (rnd.toInt % 4)
15     {
16     case 0:
17         request.stdout.write ("Chosen exception: Array index out of bounds\n");
18         char[] foo = new char[3];
19         char c = foo[10];
20     break;
21     case 1:
22         request.stdout.write ("Chosen exception: Assertion\n");
23         assert (false);
24     break;
25     case 2:
26         request.stdout.write ("Chosen exception: Exception\n");
27         throw new Exception ("My Exception");
28     break;
29     default:
30         request.stdout.write ("Chosen Exception: none\n");
31     }
32
33     return 0;
34 }
35
36 int main(char[][] args)
37 {
38     rnd = Kiss ();
39
40     FastCGIConnection connection = new FastCGIConnection ();
41
42     return FastCGIThread.loop(connection, &myrun, true, 10);
43 }
Note: See TracBrowser for help on using the browser.