From: Eckhard L. <ec...@we...> - 2006-11-02 13:34:35
|
> -----Urspr=FCngliche Nachricht----- > Von: Lars Hellstr=F6m <Lar...@re...> > Gesendet: 01.11.06 21:10:29 > An: tcl...@li... > Betreff: Re: [TCLCORE] TIP #290: Registration of Custom Error Handler Sc= ripts > 2006-11-01 kl. 15.02 skrev Eckhard Lehmann: > > This TIP proposes the possibility to register custom scripts or > > commands in the usual Tcl event handler style as error handlers. >=20 > Does "event" here have anything to do with the event loop=3F No, it has not. It's just the same "format" like commands for fileevent, w= indow event and so on. >=20 > > SPECIFICATION > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > [...] >=20 > IMHO, this is not a specification, but rather a ChangeLog. I know.. sorry, I did'nt TIP before ;-). Its updated and hopefully better = now. > Attempting to recreate a functionality description from the information=20 > given, it seems like these error handlers would be called immediately=20 > when the error is thrown, just like e.g. a variable trace is called=20 > immediately when that variable is accessed. In view of that, it might=20 > perhaps be more appropriate to fully integrate this into the [trace]=20 > command (especially since this would provide established mechanisms for=20 > introspection and handler deletion). I thought about a [trace set errorcmd] or [trace add errorcmd]. Probably y= ou're right regarding the interface to this from a Tcl'ers point of view.=20 But the internal execution mechanism is different... it's not a "normal" t= race, which runs when all the other traces are executed, but only when the= re was an error. In fact, it is called after the command execution, if nec= essary as determined by the catch level and -caught/-uncaught flags. > Come to think of it, how much of this isn't already made possible by=20 > [trace add execution]=3F If you do [trace add execution main leavestep=20 > handler], where [main] is the main procedure of your program and=20 > [handler] is your designated error handler, then this handler will=20 > indeed be called whenever a command completes, and thus be given a=20 > chance to do something for those returns that have an error return=20 > code.=20 I made a section in the TIP explaining my experiences with that. Indeed I = thought it could be solved this way, but it was somewhat tedious in practi= ce... > (Even counting [catch]es could be handled using execution traces,=20 > if one trusts the user not to rename the [catch] command.) Speed is of=20 > course an issue, but if that is the main reason for this feature then=20 > the TIP should say so. As for the [catch]'es - I don't know how to capture them in a leavestep tr= ace. Its not obvious or easy, if possible at all. The speed issue is inclu= ded in the TIP now. >=20 > The distinction between caught and uncaught errors also seem a bit=20 > hazy. Many errors are caught (by control structures and the like) just=20 > to be rethrown, but it seems as the mechanism proposed here would=20 > simply consider them to be caught.=20 No, if they are rethrown, a new error is generated which is not considered= to be caught (if not caught elsewhere above, of course). > That is probably not what a user=20 > would expect, and a control structure implementor would want a=20 > mechanism for saying "this [catch] is not to count as catching errors". The custom command can be run on either caught errors or uncaught errors, = or both (depending on the -caught/-uncaught flags given to the registratio= n command). Everything else is up to the implementor of the registered com= mand (checking ::errorCode and ::errorInfo etc.). I think that is appropri= ate... Eckhard =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F Viren-Scan f=FCr Ihren PC! Jetzt f=FCr jeden. Sofort, online und kostenlos. Gleich testen! http://www.pc-sicherheit.web.de/freescan/=3Fmc=3D022222 |