रेंडरिंगhi

पकड़ो

Translation status: हिन्दी reader-locale proof. Term names and code fences follow the hi pack; supporting prose may still be English.

Starts a catch block.

Aliases: catch

Syntax: <structured-statement> पकड़ो <name> <block>

Category#

errors

Examples#

radix/corpus/cape/cape.fab (canonical · keyword)#

Starts a catch block.

# =============================================================================
# पकड़ो — Starts a catch block.
# =============================================================================
#
# What this teaches:
#   • Error recovery — `करो { … } पकड़ो err { … }` attempts a block and catches
#     errors with a named handler
#   • Guarded execution — code inside the `करो` block can `इधरफेंको` errors that
#     are intercepted by the `पकड़ो` handler
#
# Common mistakes:
#   • attaching `पकड़ो` to a bare `{ }` block — `पकड़ो` only attaches to `करो` blocks and structured statements; use `करो { ... } पकड़ो err { ... }`
#
# See also: करो, इधरफेंको, ⇥
# =============================================================================

# पकड़ो — catch handler on करो
#
# GRAMMAR:
#   facStmt :← 'करो' block 'पकड़ो' ident block
#
# EXPECTED OUTPUT:
#   Scalar stdout smoke (see body).
#
# BACKEND:
#   Rust/Go: करो/cape emit gap (whitelist: पकड़ो/cape.fab).
#

main {
    var int attempt ← 0
    do {
        attempt ← attempt + 1
        if attempt ≻ 1 {
            throw "simulated failure"
        }
        print "attempt §"(attempt)
    }
    catch err {
        print "caught"
    }
}

Expected output:

attempt 1

radix/corpus/cape/receptio-decline.fab (supporting · reject)#

पकड़ो AIR decline rows: whole-loop जबतक/itera पकड़ो stays out under the loop-spectrum causes, a rethrow from a recovery arm declines (rethrow_in_recovery).

# =============================================================================
# receptio decline — the Tier 0.5 keep-outs stay fail-closed.
# =============================================================================
#
# Decline rows (reject reason in each comment):
#   1. whole-loop पकड़ो on `जबतक` — one trailing पकड़ो wraps the whole loop
#      (never re-armed per iteration), and the loop spectrum stays an AIR
#      keep-out: SEM059 dum_loop. A loop statement has no normal-exit
#      value, so the recovery arm also fails the outer-type rule:
#      SEM059 recovery_type_mismatch
#   2. whole-loop पकड़ो on `दोहराओ` — same per-loop attachment, same
#      keep-out: SEM059 itera_loop plus recovery_type_mismatch
#   3. rethrow — a throw from inside the catch arm is a rethrow; it
#      declines to Tier 2 fail-closed and is never silently treated as a
#      recovered value: SEM059 rethrow_in_recovery
#
# Common mistakes:
#   • expecting the trailing loop `पकड़ो` to recover per iteration — the
#      handler is per-loop by the grammar; per-iteration recovery would
#      need new syntax and its own goal
#   • expecting a rethrow to admit because the region admitted — the
#      recovery arm is checked as a catch region; throwing from it is the
#      named Tier 2 decline
#
# See also: पकड़ो, जबतक, दोहराओ, इधरफेंको, receptio-air
# =============================================================================

# 1. whole-loop पकड़ो on जबतक — loop-spectrum keep-out
@ radix लेन "air"
फलन custos_dum(तार्किक pergo) → रिक्त {
    जबतक pergo {
        इधरफेंको "x"
    } पकड़ो err { }
}

# 2. whole-loop पकड़ो on दोहराओ — loop-spectrum keep-out
@ radix लेन "air"
फलन custos_itera() → रिक्त {
    दोहराओ सीमा 0‥4 स्थिर i {
        इधरफेंको "x"
    } पकड़ो err { }
}

# 3. rethrow — a throw inside the catch arm declines to Tier 2
@ radix लेन "air"
फलन reicit(तार्किक malum) → संख्या ⇥ पाठ {
    करो {
        यदि malum { इधरफेंको "x" }
        लौटाओ 1
    } पकड़ो err {
        इधरफेंको "reicitur"
    }
    लौटाओ 2
}

Expected: compilation rejects this example.