[Ur] Catching errors
Adam Chlipala
adamc at impredicative.com
Sat May 19 11:40:09 EDT 2012
Edward Z. Yang wrote:
> Is there a way to catch an 'error<xml>asdf</xml>'? For example
> the json module uses error to indicate parse failure, and instead
> I'd like to catch it and try something else.
There's currently no way to catch errors with nestable constructs (e.g.,
exception handling as in ML), but there is [onError], as you mentioned.
The nice approach to your concrete problem would be to build alternate
parsing machinery that returns a type indicating errors. ;)
> The onError function seems like a partial mechanism for this, but
> I don't understand how scoping on onError works; if I register
> something as onError, is it permanently called on error? Is it
> displaced by the next onError I call?
Within a single client-side page execution, registered event handlers
stay registered forever. When multiple handlers are registered, they
will all run in reverse registration order. (I've added a bit about
this to the manual.)
More information about the Ur
mailing list