Re: Convenience methods for traceln
"Mark S. Miller" <[email protected]>
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Jan 7, 2011 at 8:44 AM, Mark S. Miller <[email protected]> wrote: > > > On Fri, Jan 7, 2011 at 5:55 AM, Thomas Leonard < > tal-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected]> wrote: > >> This patch makes it a bit easier to use traceln: >> >> >> http://gitorious.org/repo-roscidus/it-innovation/commit/18c3370b28586ee80eabfd8141068ff4c421bc7d > > > Question inline > With that corrected, looks good. Thanks. > > >> >> >> 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 >> >> _______________________________________________ >> e-lang mailing list >> [email protected] >> http://www.eros-os.org/mailman/listinfo/e-lang >> > > > > -- > Cheers, > --MarkM > -- Cheers, --MarkM _______________________________________________ e-lang mailing list [email protected] http://www.eros-os.org/mailman/listinfo/e-lang