[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Ignore errors while evaluating with `primitive-eval'
From: |
Mark H Weaver |
Subject: |
Re: Ignore errors while evaluating with `primitive-eval' |
Date: |
Mon, 19 Aug 2013 11:46:50 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Hi,
Alexandru Cojocaru <address@hidden> writes:
> is it possible to ignore errors when evaluating a badly formed
> expression?
Yes. An easy way is to use 'false-is-exception', like this:
(false-if-exception (primitive-eval '(this is an error)))
=> #f
However, this won't work if you need to tell the difference between the
evaluation returning #f and an error happening. In that case, try this:
(catch #t
(lambda ()
(primitive-eval '(this is an error)))
(lambda (key . args)
(display "An error occurred during evaluation.\n")))
Happy hacking!
Mark