summary refs log tree commit diff stats
path: root/doc/manual.txt
diff options
context:
space:
mode:
Diffstat (limited to 'doc/manual.txt')
-rwxr-xr-xdoc/manual.txt65
1 files changed, 42 insertions, 23 deletions
diff --git a/doc/manual.txt b/doc/manual.txt
index a85c1e753..1ef3237ec 100755
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -1969,29 +1969,6 @@ a special syntactic extension, the ``when`` construct is also available
 within ``object`` definitions.
 
 
-Raise statement
-~~~~~~~~~~~~~~~
-
-Syntax::
-
-  raiseStmt ::= 'raise' [expr]
-
-Example:
-
-.. code-block:: nimrod
-  raise newEOS("operating system failed")
-
-Apart from built-in operations like array indexing, memory allocation, etc.
-the ``raise`` statement is the only way to raise an exception.
-
-.. XXX document this better!
-
-If no exception name is given, the current exception is `re-raised`:idx:. The
-`ENoExceptionToReraise`:idx: exception is raised if there is no exception to
-re-raise. It follows that the ``raise`` statement *always* raises an
-exception.
-
-
 Try statement
 ~~~~~~~~~~~~~
 
@@ -2060,6 +2037,48 @@ in an implicit try block:
   ...
 
 
+Raise statement
+~~~~~~~~~~~~~~~
+
+Syntax::
+
+  raiseStmt ::= 'raise' [expr]
+
+Example:
+
+.. code-block:: nimrod
+  raise newEOS("operating system failed")
+
+Apart from built-in operations like array indexing, memory allocation, etc.
+the ``raise`` statement is the only way to raise an exception.
+
+.. XXX document this better!
+
+If no exception name is given, the current exception is `re-raised`:idx:. The
+`ENoExceptionToReraise`:idx: exception is raised if there is no exception to
+re-raise. It follows that the ``raise`` statement *always* raises an
+exception (unless a raise hook has been provided).
+
+
+OnRaise builtin
+~~~~~~~~~~~~~~~
+
+``system.onRaise`` can be used to override the behaviour of ``raise`` for a
+single ``try`` statement. `onRaise`:idx: has to be called within the ``try`` 
+statement that should be affected.
+
+This allows for a Lisp-like `condition system`:idx:\:
+
+.. code-block:: nimrod
+  var myFile = open("broken.txt", fmWrite)
+  try:
+    onRaise(proc (e: ref E_Base): bool =
+      stdout.writeln "ok, writing to stdout instead")
+    myFile.writeln "writing to broken file"
+  finally:
+    myFile.close()
+
+
 Return statement
 ~~~~~~~~~~~~~~~~