#6 feature fuly implemented
[svn/Cll1h/.git] / demos / exceptions / failures.c
diff --git a/demos/exceptions/failures.c b/demos/exceptions/failures.c
new file mode 100644 (file)
index 0000000..2338f7f
--- /dev/null
@@ -0,0 +1,75 @@
+#include "cll1.h"
+
+void some_function(int i)
+{
+ if(i==2)
+ {
+  fail(EVIL_FAILURE);
+ }
+ if(i==7)
+ {
+  some_function(2);
+ }
+ if(i==6)
+ {
+  fail(LOCAL_FAILURE);
+ }
+ printf("nuda #%d\n",i);
+}
+
+program
+{
+ try
+ {
+  some_function(1);
+  some_function(2);
+  some_function(6); 
+ }
+ else_switch_failures
+ {
+  case EVIL_FAILURE: puts("serious failure detected!"); break;
+  default: puts("sorry, vole, error!");
+ }
+
+ try
+ {
+  some_function(1);
+  some_function(3);
+  some_function(6); 
+  some_function(2);
+ }
+ else
+ {
+  puts("sorry, vole, error!");
+ }
+
+ try
+ {
+  some_function(1); 
+  some_function(6); 
+ }
+ else_catch(EVIL_FAILURE)
+ {
+  puts("Totally screwed.");
+  exit(-1);
+ }
+ else
+ {
+  puts("We survived this failure.");
+ }
+
+ try
+ {
+  some_function(3); 
+  some_function(7); 
+ }
+ else_catch(EVIL_FAILURE)
+ {
+  puts("totally screwed.");
+  exit(-1);
+ }
+ else
+ {
+  puts("we survived this failure.");
+ }
+}
This page took 0.164348 seconds and 4 git commands to generate.