flow: try-catch combinator — reify raised exceptions + 6 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 34s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 34s
(try-catch node handler) runs node; on a raised exception calls (handler error) with the reified error via Scheme guard, returns the handler value. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
;; (fail reason) — make an explicit failure value (data, not an exception)
|
||||
;; (failed? x) — is x a failure value?
|
||||
;; (fail-reason x) — the reason carried by a failure value
|
||||
;; (try-catch node handler) — run node; if it raises, call (handler error)
|
||||
;; with the reified error and return the handler's value
|
||||
|
||||
(define
|
||||
flow-combinators-src
|
||||
@@ -29,7 +31,7 @@
|
||||
|
||||
(define
|
||||
flow-control-src
|
||||
"(define (branch pred then else)\n (lambda (input) (if (pred input) (then input) (else input))))\n (define (fail reason) (list (quote flow-fail) reason))\n (define (failed? x) (and (pair? x) (eq? (car x) (quote flow-fail))))\n (define (fail-reason x) (car (cdr x)))")
|
||||
"(define (branch pred then else)\n (lambda (input) (if (pred input) (then input) (else input))))\n (define (fail reason) (list (quote flow-fail) reason))\n (define (failed? x) (and (pair? x) (eq? (car x) (quote flow-fail))))\n (define (fail-reason x) (car (cdr x)))\n (define (try-catch node handler)\n (lambda (input) (guard (e (#t (handler e))) (node input))))")
|
||||
|
||||
(define
|
||||
flow-load-combinators!
|
||||
|
||||
Reference in New Issue
Block a user