[REBOL] Re: Centralise error trapping in REBOL/View applications
From: lmecir:mbox:vol:cz at: 16-Aug-2007 18:19
Rudolf W. MEIJER napsal(a):
> I appreciate all the comments received on my suggestion, but would like
> to
> say that my point was twofold: to highlight the manipulation ability of
> REBOL, allowing to dynamically compute a function name [handler: get
> to-word
> join "handle-" suffix]
to dynamically compute a function name
- it is of little advantage in
this case, when the name of the function to call is known
> and the more accurate error-logging that is made
> possible by trapping errors at handler level rather than at <view
> layout>
> level.
error logging accuracy - did you find any interesting difference?
> BTW, if one wants to have the equivqalent of [try [view layout]]
> with
> RebGUI, where the windows application is started by [display title
> window]
> followed by [do-events], I suppose the trap is on the latter function:
> [[try
> [do-events]]. Right?
>
> Rudolf Meijer
Try [do-events] is possible, but a more flexible way is to change the
implementation of the Do-events function to suit your needs, example:
do-events-with-error-handling: func [
{
Usage:
view/new my-layout
do-events-with-error-handling :my-error-handler
}
handle-error [function!] {
Error handling function.
Arguments:
error [error!] - the error that is being handled
Return value:
True - stop handling events
False - continue handling events
}
] [
until [handle-error try [return wait []]]
]
-L