You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the core feature is error handling (failed clause). It would be nice to have named status codes. I think of it as a C# enum. Basically they are just integer constants (Num without fractional part).
Example:
// 7za https://man.archlinux.org/man/7za.1.en#DIAGNOSTICS
status L7zaStatus { // Pascal case as other Amber types
Success = 0,
Warning = 1,
Fatal = 2,
BadCommandLineParameters = 7,
NotEnoughMemory = 8,
UserCancel = 255,
}
main {
let archive = "path/to/archive.7z"
$7za x {archive}$? failed {
if {
status == L7zaStatus.UserCancel {
echo "user canceled "
}
// ... other exit codes...
else {
echo "unknown error {status}"
}
}
}
}
They can be defined in library (pub + import):
// lib.ab
pub status Foo {
...
}
// app.ab
import { Foo } from "lib.ab"
EDIT:
Function could somehow specify its status type:
fun foo_bar(a: Num, b: Num) -> Num fail L7zaStatus {
// ...
fail L7zaStatus.Fatal
}
foo_bar(1, 2) failed {
if status == L7zaStatus.Fatal { // <-- code completion in IDE provides list of L7zaStatus items
// ...
}
if status == 42 {} // <-- it is ok to use Num
}
The text was updated successfully, but these errors were encountered:
One of the core feature is error handling (
failed
clause). It would be nice to have named status codes. I think of it as a C# enum. Basically they are just integer constants (Num
without fractional part).Example:
They can be defined in library (
pub
+import
):EDIT:
Function could somehow specify its status type:
The text was updated successfully, but these errors were encountered: