This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: The taming of gh_eval_str()


Russ McManus <mcmanus@IDT.NET> wrote:

> Eric Buddington wrote:
> 
> > I'm still trying to pound guile into my code, with various frustrations.
> >
> > At the moment, I have guile successfully starting up in an isolated
> > thread, and evaluating strings passed to it by other threads. I'm having
> > two straightforward (I hope) problems:
> 
> Been there, done that.
> 
> > 1) Passing garbage input to gh_eval_str() causes guile to spit out an
> > error and *exit*, thus taking down my entire server. This is not desirable
> > behavior. What is the proper way to trap/display such errors and avoid
> > termination?
> 
> wrap some scheme code around the scheme code that does actual work,like this,
> roughly (_danger_ untested code):
> 
> (define (do-real-work)
>   ;; blah
>   )
> 
> (define (do-work)
>     "this one get called from C++"
>     (catch #t  ;; catches all exceptions
>        (lambda () (do-real-work))
>        (lambda (tag .  args)
>           (for-each display `("caught error with tag " ,tag " and args " args
> "\n")
>           #f)
>      #t)
> 
> Then C++ can test whether there was an error by looking at the return value
> from do-work.

check out `false-if-exception' in ice-9/boot-9.scm.  similar.

thi