Convenience methods for traceln
Thomas Leonard <tal-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected]>
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Organization | IT Innovation |
| Message-ID | <1294408541.1940.12.camel@farnia> |
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-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected]
http://www.it-innovation.soton.ac.uk