-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
along with docs and test cases
- Loading branch information
Showing
8 changed files
with
198 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
= The catch Statement | ||
|
||
.Syntax | ||
[source,unlang] | ||
---- | ||
try { | ||
... | ||
} | ||
catch { | ||
[ statements ] | ||
} | ||
---- | ||
|
||
The `catch` statement runs a series of substatements in a block, but only if the previous xref:unlang/try.adoc[try] failed. | ||
|
||
[ statements ]:: The `unlang` commands which will be executed. A | ||
`catch` block can be empty. | ||
|
||
.Example | ||
|
||
[source,unlang] | ||
---- | ||
try { | ||
sql | ||
} | ||
catch { | ||
# ... run only if sql failed | ||
} | ||
---- | ||
|
||
There is some overlap in functionality between `try` / xref:unlang/catch.adoc[catch] and xref:unlang/redundant.adoc[redundant]. The main difference (TODO) is that a xref:unlang/catch.adoc[catch] statement can catch specific actions. | ||
|
||
// Copyright (C) 2023 Network RADIUS SAS. Licenced under CC-by-NC 4.0. | ||
// This documentation was developed by Network RADIUS SAS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
= The try Statement | ||
|
||
.Syntax | ||
[source,unlang] | ||
---- | ||
try { | ||
[ statements ] | ||
} | ||
catch { | ||
... | ||
} | ||
---- | ||
|
||
The `try` statement runs a series of substatements in a block. If the | ||
block returns an error such as `fail`, `reject`, `invalid`, or | ||
`disallow`, a subsequent xref:unlang/catch.adoc[catch] block is | ||
executed. | ||
|
||
[ statements ]:: The `unlang` commands which will be executed. A | ||
`try` block cannot be empty. | ||
|
||
Every `try` block must be followed by a xref:unlang/catch.adoc[catch] | ||
block. | ||
|
||
.Example | ||
|
||
[source,unlang] | ||
---- | ||
try { | ||
sql | ||
} | ||
catch { | ||
# ... run only if sql failed | ||
} | ||
---- | ||
|
||
There is some overlap in functionality between `try` / xref:unlang/catch.adoc[catch] and xref:unlang/redundant.adoc[redundant]. The main difference (TODO) is that a xref:unlang/catch.adoc[catch] statement can catch specific actions. | ||
|
||
// Copyright (C) 2023 Network RADIUS SAS. Licenced under CC-by-NC 4.0. | ||
// This documentation was developed by Network RADIUS SAS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# PRE: if | ||
# | ||
string foo | ||
string bar | ||
|
||
try { | ||
&foo := "hello" | ||
|
||
fail | ||
|
||
&bar := "nope" | ||
} | ||
catch { | ||
if &foo != "hello" { | ||
test_fail | ||
} | ||
|
||
if &bar { | ||
test_fail | ||
} | ||
|
||
success | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
string foo | ||
|
||
try { # ERROR | ||
&foo := "foo" | ||
} | ||
|
||
# | ||
# No "catch" - that's an issue | ||
# | ||
|
||
if &foo != "foo" { | ||
test_fail | ||
} |