Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

supressing errors

23 views
Skip to first unread message

Lisa Pearlson

unread,
Dec 27, 2005, 5:35:43 PM12/27/05
to
My script implements a socket server. When a client connects and an error
occurs, the error is dumped to the client (using STDIN/STDOUT with XINETD).
This reveils information to the client that I do not wish to have reveiled
(for security purposes).

I try to test all input from client so errors will not occur. Additionally I
might try enclosing functions that could fail into a try/catch block. But
just to cover everything, is there a way to supress error messages to
stdout.. I rather have the error messages dumped to a file ONLY or better
yet, have some kind of callback function like "on_Error" that is passed the
error string that otherwise would be dumped to STDOUT. Then I can choose to
puts this or write it to a log file or something.

Lisa


Michael Schlenker

unread,
Dec 27, 2005, 5:52:47 PM12/27/05
to
Lisa Pearlson schrieb:
If you wrap your code in 'catch' the error messages are placed in the
var given as second argument to catch. For event handlers you may be
interested in defining a bgerror procedure.

Michael

Roy Terry

unread,
Dec 27, 2005, 5:53:31 PM12/27/05
to
"Lisa Pearlson" <n...@spam.plz> wrote in message
news:43b1c191$0$20191$e4fe...@dreader30.news.xs4all.nl...
Since you are writing a server, all the action after
startup will be taking place in response to events like filereadable.
In that case you can define a function "bgerror" which Tcl will
call when an uncaught error is detected while processing a
background event.
http://www.tcl.tk/man/tcl8.4/TclCmd/bgerror.htm

For errors encoutered during your startup (foreground) sequence the
only suggestion is what I call "the big catch" - wrap all
or most of your code in a single giant catch command.
Of course it would probably be better to intelligently
wrap as needed but you asked about blanket coverage.
There is no way I recall just now to make Tcl just ignore errors.
They need to be caught.

Roy

>
> Lisa
>
>


Lisa Pearlson

unread,
Dec 27, 2005, 9:19:12 PM12/27/05
to
put them all in a 'catch' block? don't you mean I should put all my code in
a 'try' block?

seems exceptions package is not standard part of tcl distribution, or
tcllib. :(

Lisa

"Roy Terry" <royt...@earthlink.net> wrote in message
news:LBjsf.3058$nu6....@newsread1.news.pas.earthlink.net...

sleb...@gmail.com

unread,
Dec 28, 2005, 12:15:58 AM12/28/05
to
Lisa Pearlson wrote:
> put them all in a 'catch' block? don't you mean I should put all my code in
> a 'try' block?
>

'catch' in Tcl roughly is the same as 'try' in other languages.

> seems exceptions package is not standard part of tcl distribution, or
> tcllib. :(
>

It is. In fact it is built in to the interpreter. Read about the
'catch' command.

0 new messages