<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/15365" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2008-02-09T20:18:36-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/15365</id>

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-02-09T20:18:36-04:00</updated>

		<published>2008-02-09T20:18:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=80788#p80788</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=80788#p80788"/>
		<title type="html"><![CDATA[debug information]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=80788#p80788"><![CDATA[
The error-reporting in eggdrop does not rely on tracing errorInfo or such. Instead, each mechanism that invokes tcl-code checks the return-status, and if an error condition is present, sends this to the MISC logqueue.<br><br>The only option left would be to rewrite eggdrop's source, namely the error reporting mechanism, and make it dump all the info. Have a look at the trigger_bind() function in tclhash.c for an example on how the error logging is done.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Feb 09, 2008 8:18 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2008-02-09T18:40:56-04:00</updated>

		<published>2008-02-09T18:40:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=80786#p80786</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=80786#p80786"/>
		<title type="html"><![CDATA[debug information]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=80786#p80786"><![CDATA[
Many thanks for your input. I'll give it some thought. Doubtful however that any changes to my other scripts proffer a generic solution, since my intention has been to make the script publicly available for users to find and trace errors on any script from any author they might have loaded.<br><br>Let me rephrase the question though. If a caught error writes to errorInfo then how is it prevented from ouputting to the partyline? Perhaps tcl errors that are output normally to the partyline are via something other than changes to errorInfo?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Sat Feb 09, 2008 6:40 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-02-09T13:13:01-04:00</updated>

		<published>2008-02-09T13:13:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=80778#p80778</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=80778#p80778"/>
		<title type="html"><![CDATA[debug information]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=80778#p80778"><![CDATA[
Since the errorInfo variable is trace'd, this would still trigger on caught errors, and in the case where you (re)set errorInfo, would cause double-triggering.<br><br>Also, Sir_Fz, you've got the number of arguments for catch wrong...<br><br>All in all, it's an interresting approach. Unfortunately, you'll run into these issues with scripts that actually do their own error-handling (as they should) rather than just blindly ignoring them and hoping for the best.<br><br><br>One approach however, might be to change from tracing errorInfo, into actually rewriting loaded scripts on the fly, making them call a function to report the error:<br>That is, change things like this (and yes, this is intentionally written VERY poorly, don't ever code something like this, EVER!!!):<div class="codebox"><p>Code: </p><pre><code>proc myUnsafeProc {nick host hand chan text} {  puthelp "PRIVMSG $chan :[lindex $text 0]"  return 0}</code></pre></div>Into something like this (still bad code, but atleast it has some error handling):<div class="codebox"><p>Code: </p><pre><code>proc myUnsafeProc {nick host hand chan text} {  if {[catch {    puthelp "PRIVMSG $chan :[lindex $text 0]"    return 0  } error]} {    reportError $error $::errorInfo $::errorCode    error $error $::errorInfo $::errorCode  } else {    return $error  }}</code></pre></div>This should not interfere with most scripts that do their own error-handling, although it might be a good idea to implement a feature to "whitelist" proc's that don't like being mangled... Also, this will still generate the error in question, so scripts that rely on subcalls generating errors in certain condition should'nt be too upset.<br><br>Basic approach would be something like this:<div class="codebox"><p>Code: </p><pre><code>foreach process [info proc] {  proc $process [info args $process] "  if {\[catch {  [info body $process]  } error \]} {    reportError \$error \$::errorInfo \$::errorCode    error \$error \$::errorInfo \$::errorCode  } else {    return \$error  }"}</code></pre></div>Problem here however, is that you'd have to make sure this piece of code is not executed until all other scripts have been loaded and created all procs necessary.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Feb 09, 2008 1:13 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2008-02-09T15:15:20-04:00</updated>

		<published>2008-02-09T12:15:16-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=80775#p80775</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=80775#p80775"/>
		<title type="html"><![CDATA[debug information]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=80775#p80775"><![CDATA[
Another solution is to override Tcl's [catch] command with your own, try this:<div class="codebox"><p>Code: </p><pre><code>rename catch _catchproc catch arg { if {[_catch $arg]} {  set errorInfo ""  return 1 } return 0}</code></pre></div>Not tested.<br><br>Edit: Yes nml375 you're right about the number of arguments for [catch], so let's consider the above as just an example. In case such an override should be made, check <a href="http://www.tcl.tk/man/tcl8.4/TclCmd/catch.htm" class="postlink">catch</a> man-page.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Sat Feb 09, 2008 12:15 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2008-02-09T12:02:42-04:00</updated>

		<published>2008-02-09T12:02:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=80774#p80774</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=80774#p80774"/>
		<title type="html"><![CDATA[debug information]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=80774#p80774"><![CDATA[
A solution would be to add some custom word to errorInfo in case the error is caught, for example:<div class="codebox"><p>Code: </p><pre><code>if {[catch {&lt;code-here&gt;} error]} { set errorInfo "CAUGHT: $error"}</code></pre></div>So in your script you parse errorInfo to see if it contains the keyword CAUGHT, otherwise it's an uncaught-error.<br><br>It's not a "good" solution of course since you'll have to edit other scripts instead of just debug.tcl to do it.<br><br>Edit: Or you can simply set errorInfo "" in case the error is caught (instead of adding a keyword).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Sat Feb 09, 2008 12:02 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2008-02-09T07:28:29-04:00</updated>

		<published>2008-02-09T07:28:29-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=80772#p80772</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=80772#p80772"/>
		<title type="html"><![CDATA[debug information]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=80772#p80772"><![CDATA[
I have a script debug.tcl (published to egghelp) which, rather than the minimal error messages that show in the partyline, gives a full trace on any errors that occur using the variable errorInfo. This can be very useful if, in the script causing the error, a proc calls a proc that calls a proc etc that generates the error.<br><br>Whilst the script performs as expected, there is one, sometimes annoying, aspect of its performance that I would like to change. This concerns errors generated from a catch statement. An error trapped by a catch statement does not show in the partyline but yet does write to errorInfo, as a consequence my script picks it up and generates an output.<br><br>I am thinking therefore that there is a discernable difference between such errors that causes the normal partyline message to be nullified in the case of properly caught errors. Perhaps something within tclvars. I would ideally like to employ a user configured variable within my script to give the choice of showing caught errors or not.<br><br>Any thoughts on how to identify the difference between a genuine error and one trapped by a catch statement would be appreciated.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Sat Feb 09, 2008 7:28 am</p><hr />
]]></content>
	</entry>
	</feed>
