[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] catch read & load errors?
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] catch read & load errors? |
Date: |
Thu, 4 Aug 2005 14:41:25 +0200 |
On 8/4/05, Michael Benfield <address@hidden> wrote:
> Hi -
>
> I'm pretty new to Scheme in general and Chicken in particular. Both are
> awesome.
Thanks for giving it a try!
>
> I'm wondering, though, is it possible to catch the errors generated by
> functions like read or load when they encounter bad syntax? I'd like to
> be able to use read to parse things or load to load files from within
> my program, but I can't do that if bad user input will just terminate
> my program. Or is there a different way to do this?
>
You could simply use exception-handling:
(handle-exception ex (...do something with the exception in "ex" ...)
(read) )
Or, alternatively `condition-case', see also:
http://www.call-with-current-continuation.org/manual/Exceptions.html#Exceptions
Read errors normally raise an exception of tthe kinds 'exn and `syntax.
cheers,
felix