[Ur] Exceptions handling
Vladimir Shabanov
vshabanoff at gmail.com
Sun Aug 29 18:19:22 EDT 2010
2010/8/24 Adam Chlipala <adamc at impredicative.com>:
> Vladimir Shabanov wrote:
>>
>> And there is another way to check DML errors -- another function dml'
>> can be adder which returns option string instead of error page, e.g.
>> result<- dml' (...);
>> case result of
>> None => return "ok"
>> Some e => return strcat("dberror: ", e)
>>
>
> I like this suggestion. The key issue is deciding which database errors
> should be returned in this way. An error like "lost connection to server"
> should still abort execution, IMO, since it's outside of the abstraction
> that Ur/Web is meant to present to the programmer. A corollary issue is
> which methods should be used with each database system's C library to filter
> out the appropriate errors.
I think that constraint violations should be returned (ideally with
name of constraint), other errors (except errors that Ur's runtime
can't handle -- like connection issues) can be just returned as string
so they still can be handled even without native Ur support.
Custom error form is also good thing -- it can be some
string->transaction page function referenced from .urp-file.
And there can be custom rpc-error handler, something like:
<body onError={set errorHappened true} ...>
More information about the Ur
mailing list