[plt-scheme] Displaying an error message and continuing

From: Greg Woodhouse (gregory.woodhouse at sbcglobal.net)
Date: Wed Jan 17 18:58:07 EST 2007

I have a situation where I want to be able to break out of a loop (actually, a named let) and continue with the next iteration upon catching exn:fail:user (or perhaps a subclass). The idea is that most errors should be fatal, but I'm building a little REPL based application, and if input is badly formed, or if certain run-time exceptions occur, I just want to go back to the input prompt. Of course, I want breaks, and any errors that occur during evaluation other than errors in my interpeter to terminate the loop.

Now, I'm using with-handlers, and simply use (loop), where loop is the label in the named let, to "continue" with the next iteration. Now, here's the problem: Instead of using (error ...) to raise an exception, I'm using (raise-user-error ... ) so that I get an instance of exn:fail:user, but I want to be able to display the error string that is used in the call to raise-user-error. Is this possible? Do I need an error display handler (not that I would know how)?
Gregory Woodhouse 
"Mathematics is the science of patterns."
--Lynn Arthur Steen, 1988

Posted on the users mailing list.