[e-lang] Convenience methods for traceln

Mark S. Miller erights at google.com
Fri Jan 7 08:44:53 PST 2011


On Fri, Jan 7, 2011 at 5:55 AM, Thomas Leonard <
tal at it-innovation.soton.ac.uk> wrote:

> This patch makes it a bit easier to use traceln:
>
>
> http://gitorious.org/repo-roscidus/it-innovation/commit/18c3370b28586ee80eabfd8141068ff4c421bc7d


Question inline


>
>
> 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
>
> _______________________________________________
> e-lang mailing list
> e-lang at mail.eros-os.org
> http://www.eros-os.org/mailman/listinfo/e-lang
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.eros-os.org/pipermail/e-lang/attachments/20110107/cc8e08a3/attachment.html 


More information about the e-lang mailing list