Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

[PATCH] eval hides exception source in helpers

#25

The use of 'eval' hides the true location of exceptions in helpers. For example, just try

telnet localhost 1337
GET /collab HTTP/1.1
<<blank line>>

The error given is:

[2008-04-03 15:58:49] ERROR TypeError: can't convert nil into String
        (eval):442:in `+'
        (eval):442:in `do_GET'

which doesn't identify which file the error occured in.

After the following patch is applied:

--- /usr/lib/ruby/gems/1.8/gems/adhearsion-0.7.7/ahn.orig       2008-04-03 14:21:39.000000000 +0100
+++ /usr/lib/ruby/gems/1.8/gems/adhearsion-0.7.7/ahn    2008-04-03 15:59:33.000000000 +0100
@@ -207,7 +207,7 @@
         if config.delete('enabled') != false
          log "Parsing helper #{name}"
           $HELPERS[name] = config
-          eval File.read(f)
+          load f
         end
       end
     end

then the exception becomes clearer:

[2008-04-03 16:00:18] ERROR TypeError: can't convert nil into String
        ./helpers/micromenus.rb:442:in `+'
        ./helpers/micromenus.rb:442:in `do_GET'

(Maybe there is some reason why eval File.read(f) is used instead of load(f), but I can't think of one)

Reported by Brian Candler · April 3rd, 2008 @ 11:05 AM

State: resolved
Milestone: none
Assigned to: Jay Phillips Jay Phillips

Activity

  1. Jay Phillips
    Jay Phillips
    • State changed from new to resolved

    Hi bcandler,

    (I posted this on your other patch too. Including it here too for the archive.)

    Thanks a TON for the patch! I always love it when I see people get involved in the software development process. :)

    Though there won't be another release of 0.7.x, I will definitely use these patches in the refactored version of Micromenus that will be included in 0.8.x.

    Thanks!

    Jay Phillips

    April 3rd, 2008 @ 06:23 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.