Hi,
I wonder if there is a way in SBCL and CL in general, whenever any kind of error happens (undefined variable, division by zero, type error, etc.),
to prevent the debugger from popping up and then catch the error message string to display it / write it somewhere else.
Basically, I'm controlling SBCL via shell commands from inside another environment (MaxMSP).
My system in Max aims at teaching Lisp to musicians with dynamic visual interfaces,
so I want my users to be able to understand what's going on without going to the terminal themselves.
The shell object in Max can send shell commands and get its results successfully (anything that went through a PRINT function in SBCL)
but the debugger doesn't seem to take place in the same space.
Let's say I send the following command :
sbcl --core some/path/to/a/.core/file --script my/script/generated/in/maxmsp
If there's an error inside my script, in the terminal the debugger would show up then quit immediately — but Max would just show nothing until the next valid script.
What I would like to do is intercept the error message, such as
"The value 'TOTO is not of type NUMBER when binding SB-KERNEL::X",
without having to create all kinds of exceptions.
Any suggestions will be highly welcome, thanks in advance !
Best,
Julien
Catch error message in SBCL
-
- Posts: 166
- Joined: Sun Nov 28, 2010 4:21 pm
Re: Catch error message in SBCL
Hello a bit late
What about simply catching all conditions with `handler-case` and printing the condition, with a regular `(format t "~a" …)`?
What about simply catching all conditions with `handler-case` and printing the condition, with a regular `(format t "~a" …)`?
Code: Select all
(handler-case
(start-the-core-app)
(error (c)
(format t "An unexpected error happened: ~a" c)))