अस्वीकार
Translation status: हिन्दी reader-locale proof. Term names and code fences follow the hi pack; supporting prose may still be English.
Reject a condition or throw a recoverable error.
Aliases: reject
Syntax: अस्वीकार <expression> इधरफेंको <expression>
Category#
errors
Related#
Examples#
radix/corpus/meta/reice.fab (canonical · keyword)#
Reject a condition or throw a recoverable error.
# =============================================================================
# अस्वीकार — Reject a condition or throw a recoverable error.
# =============================================================================
#
# What this teaches:
# • Reject guard — `reject <condition> throw <error>` throws into the
# function's ⇥ channel when the condition is true (en surface of `अस्वीकार`)
# • Boolean opposite of `require` — `require not (p) throw e` becomes
# `reject p throw e`; no hand-rolled negation
# • Typed payload — the true-path expression is a `variant`, the same shape
# used at constructor guard ladders
#
# Common mistakes:
# • Using `reject` in a function without `⇥ E` — SEM010 `iace_requires_alternate_exit`, same as `throw`
# • Reading `reject` as `require` — it fails when the condition HOLDS
#
# See also: आवश्यक, पुष्टि, इधरफेंको, पकड़ो, ⇥
# =============================================================================
# अस्वीकार — recoverable reject statement
#
# reject <condition> throw <error>
#
# GRAMMAR:
# reiceStmt :← 'अस्वीकार' expr 'इधरफेंको' expr
#
# EXPECTED OUTPUT:
# empty — success-path main only (reice.expected)
union GuardError {
Invalid { string causa }
}
fn guarded(int value) → int ⇥ GuardError {
reject value ≺ 0 throw variant Invalid { causa = "value must not be negative" }
return value
}
main {
do {
const int ok ← guarded(1)
assert ok ≡ 1
}
catch err {
assert false panic "success path must not throw"
}
}
test "true path is recoverable" {
do {
const int dropped ← guarded(-1)
assert false panic "true path must throw"
}
catch err {
# recovered — reject entered ⇥ and catch intercepted it
}
}