Tcl/Tk error handling
Filip Konvička
filip.konvicka.removethisantispamtoken at logis.cz
Wed Aug 2 10:10:19 CEST 2006
Hi all,
while solving some issues with the TclODBC library, I've created the
following wrappers for Tk.send and Tk.return. The problem I've been
trying to solve was that when a Tcl/Tk call failed, an error was printed
to stderr and the Oz script froze. The wrappers below throw an exception
when an error occurs, and Oz--Tcltk communication is in a consistent
state after such event.
proc {TkSafeSend X}
case {Tk.returnInt 'catch'(v("{") X v("}") 'tk_safe_send_msg')}
of 0 then skip
else
E={Tk.returnString set('tk_safe_send_msg')}
in
{Wait E}
raise tk_error(E) end
end
end
fun {TkSafeReturn X}
case {Tk.returnInt 'catch'(v('{set tk_safe_return_result ') l(X)
v('}') 'tk_safe_return_msg')}
of 0 then
{Tk.return set('tk_safe_return_result')}
else
E={Tk.returnString set('tk_safe_return_msg')}
in
{Wait E}
raise tk_error(E) end
unit
end
end
Cheers,
Filip
More information about the mozart-users
mailing list