smalltalk: Exception/on:do:/ensure:/ifCurtailed: + 15 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-25 10:31:59 +00:00
parent fdd8e18cc3
commit 0b5f3c180e
4 changed files with 218 additions and 1 deletions

View File

@@ -391,6 +391,17 @@
(st-parse-method "selector: aSym selector := aSym"))
(st-class-add-method! "Message" "arguments:"
(st-parse-method "arguments: anArray arguments := anArray"))
;; Exception hierarchy — Smalltalk's standard error system on top of
;; SX's `guard`/`raise`. Subclassing Exception gives you on:do:,
;; ensure:, ifCurtailed: catching out of the box.
(st-class-define! "Exception" "Object" (list "messageText"))
(st-class-add-method! "Exception" "messageText"
(st-parse-method "messageText ^ messageText"))
(st-class-add-method! "Exception" "messageText:"
(st-parse-method "messageText: aString messageText := aString. ^ self"))
(st-class-define! "Error" "Exception" (list))
(st-class-define! "ZeroDivide" "Error" (list))
(st-class-define! "MessageNotUnderstood" "Error" (list))
"ok")))
;; Initialise on load. Tests can re-bootstrap to reset state.