
I only started getting recursion for real with Little Schemer. Great book.

@ahmadrasyidsalim has joined the channel

@robbiehk131 has joined the channel

Does anybody know how to get the message of an error? I want to do something like: (check-equal? (function-being-run).errormessage() "expected error message")
And I know in C++, we can do: try { something } catch (exn) { return exn.what()}
Is there a Racket equivalent?

You can use check-exn
to check for exception types (https://docs.racket-lang.org/rackunit/api.html?q=check-exn#%28def._%28%28lib._rackunit%2Fmain..rkt%29._check-exn%29%29) but if you really want to check the exception message itself you can use : (check-equal? (with-handlers ([exn? (λ (e) (exn-message e))]) ...)
"the expected error message")

with-handlers
is the catcher basically

check-exn
also accepts a regexp argument, so there’s no need for with-handlers
.

Ha, first time I notice that! :slightly_smiling_face:

(although I never feel comfortable checking the message itself)

Thanks guys! check-exn
solved the problem!