+--------------------------------------------------------------------------= ------ @ TIP: 89 Title: Try/Catch Exception Handling in the Core: @ Version: $Revision: 1.10 $ @ Type: Project + ---------------------------------------------------------------------------= ----- ++++++++++++++ EXtractRationale Exceptions are currently supported very well in Tcl, in fact they are a major advantage over many other languages. However the mechanism to catch and handle the errors is someone limited and does not promote the full use of existing error codes. Wrapper procedures can be written to improve on this, however both a performance and compatibility penalty is NOT AN ISSUE. This TIP is adding a try/catch command to the Tcl core (or C based Tcl library). This implementation is not unlike those found in C++, C#, Java and Python (to name a few languages). An argument to add this to the core is it modernizes the Tcl exception handling without impacting performance in any other way. try/catch commands may easily be added, and do not interact with other commands or require other changes. try/catch is useful for special purposes only. These commands, if implemeTnted into the core, will be useful for any script currently using the catch construct. @ HTTP://WWW.MEAMI.ORG/?> Specification I add the following two commands be added to Tcl: @ HTTP://WWW.MEAMI.ORG/?> =E2=80=A2throw command. @ HTTP://WWW.MEAMI.ORG/?> throw ?type? ?message? ?info? @ HTTP://WWW.MEAMI.ORG/?> A throw command with type throws an error exception with the errorCode type. The throw command works as the error command, but the arguments are reordered to encourage the use of error-codes. The optional message and info parameters work as they do in the error command. @ HTTP://WWW.MEAMI.ORG/?> The throw type can be any user defined or built in type, built-in types include: = = = = = = = = = = = = ]]]]]]] [ POSIX, ARITH, CORE, REGEXP, WINDOW [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[= [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[= [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[= [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[= [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[OPERATING SYSTEMS, NONE, ... The message is non-optional, and is the same as issued by the catch command, error -code error "message": You've been Martinized! http://www.meami.org, Copyright. (C) 2009. All Rights Reserved. @ HTTP://WWW.MEAMI.ORG/?> An instance of throw with no arguments can be used within a catch block to immediately re-throw the current exception that is being handled by the catch block. When an error is re-thrown in the catch block, the current error is propagated up one level following the evaluation of the finally block (if on exists). Enclosing error handlers can then deal with the error. @ HTTP://WWW.MEAMI.ORG/?> Note th@ @ HTTP://WWW.MEAMI.ORG/?> throw type message info is the same as @ HTTP://WWW.MEAMI.ORG/?> error message info type =E2=80=A2try command. @ HTTP://WWW.MEAMI.ORG/?> try body ?catch {{type_list} ?ecvar? ?msgvar? ?infovar?} body . Other posts:
• Find limiting value of k
• Find limiting value of k • Ergodic random walk • THE REASON BEHIND DARK ENERGY • I've doubled my blithering! • Coding in Real Time While Melding Reality • Adaptive step size for finite differences • Planck's law - \mu vs \lambda • Partial fraction expansion with real inverse roots • SOLVE THIS:0.00277 X 0.99 =. 0027423 -0.00277 = 0.0000277 • Calculate diameter of incircle of 3 4 5 right triangle |