]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
update docs
authorAlan T. DeKok <aland@freeradius.org>
Fri, 15 Dec 2023 14:18:36 +0000 (09:18 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 15 Dec 2023 14:18:36 +0000 (09:18 -0500)
doc/antora/modules/reference/pages/unlang/catch.adoc
doc/antora/modules/reference/pages/unlang/try.adoc

index 6f8714bd5a938ac9f6c3984b13bc02413189b2ef..9f4d7b6aed9640c7d444e8ffc3e7fa49463d3520 100644 (file)
@@ -20,17 +20,27 @@ The `catch` statement runs a series of substatements in a block, but only if the
 
 If no rcode is given the `catch` statement matches all of the codes listed above.  Otherwise, the `catch` statement matches one of the listed rcodes.
 
-Multiple `catch` statements cam ne give
+Multiple `catch` statements can be placed one after the other, to `catch` different errors.  Only one of the statements will be executed.  Once a `catch` statement is finished, the interpreter will skip all trailing `catch` statements, and continue executio
 
 .Example
 
 [source,unlang]
 ----
 try {
-       sql
+    sql           # returns "fail"
 }
-catch {
-       # ... run only if sql failed
+catch disallow {  # skipped when "fail"
+    ...
+}
+
+catch fail {
+    # ... run only if sql failed
+
+    ok            # over-ride the "fail" code
+}
+
+catch invalid {   # skipped after "catch fail" is run.
+       ...
 }
 ----
 
@@ -41,5 +51,7 @@ one of many similar modules.  For example, the xref:unlang/redundant.adoc[redund
 
 In contrast, the `try` / `catch` statements should be used for more complex policies, when the intention is to run one policy, and then do something completely different if a failure occurs.
 
+The `try` / `catch` statements can also run different statements for each failure code, which is not possible with xref:unlang/redundant.adoc[redundant].
+
 // Copyright (C) 2023 Network RADIUS SAS.  Licenced under CC-by-NC 4.0.
 // This documentation was developed by Network RADIUS SAS.
index 74d710f7e5380c3621217053e7fdab4b40a8db0a..31224dfeffd390ce507c53bd137a204f30b52184 100644 (file)
@@ -31,6 +31,8 @@ try {
 }
 catch {
        # ... run only if sql failed
+
+       ok      # over-ride the "fail" code
 }
 ----