[e-lang] Convenience methods for traceln

Thomas Leonard tal at it-innovation.soton.ac.uk
Fri Jan 7 05:55:41 PST 2011


This patch makes it a bit easier to use traceln:

http://gitorious.org/repo-roscidus/it-innovation/commit/18c3370b28586ee80eabfd8141068ff4c421bc7d

You can now pass any object to run/1, not just a string. For example, to
dump a couple of variables:

def x := 4
def y := null
traceln([ => x, => y ])

will display:

WARNING: ["x" => 4, "y" => null]

If you pass a Throwable, it will add the E stack-trace, so you can now
do:

try {
	...
} catch ex {
	traceln(ex)
}

Finally, there's a two argument form if you want to include a message:

try {
	...
} catch ex {
	traceln("error doing ...", ex)
}

I added these because I've found that people usually start with:

  traceln(`$ex`)

Then, when it eventually gets triggered and the output isn't useful,
they extend it to this:

  traceln(`$ex: ${ex.eStack()}`)


-- 
Dr Thomas Leonard
IT Innovation Centre
2 Venture Road
Southampton
Hampshire SO16 7NP

Tel: +44 0 23 8076 0834
Fax: +44 0 23 8076 0833
mailto:tal at it-innovation.soton.ac.uk
http://www.it-innovation.soton.ac.uk 



More information about the e-lang mailing list