sugar-framework / sugar

Modular web framework for Elixir
https://sugar-framework.github.io/
MIT License
430 stars 29 forks source link

compile error when set `show_debugger` to `true` in config.ex #72

Closed horx closed 9 years ago

horx commented 9 years ago

Hi, when I set the show_debugger option to true in config.ex, then restart the server, It always raise exception like this:

** (UndefinedFunctionError) undefined function: Plug.Debugger.init/1
    Plug.Debugger.init([otp_app: :etie])
    lib/plug/builder.ex:112: Plug.Builder.init_module_plug/3
    lib/plug/builder.ex:99: anonymous fn/2 in Plug.Builder.compile/1
    (elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
    lib/plug/builder.ex:99: Plug.Builder.compile/1
    expanding macro: HttpRouter.__before_compile__/1
    lib/etie/router.ex:1: Etie.Router (module)

and the version of Sugar in my app is 0.4.6. Did I do something wrong ?

slogsdon commented 9 years ago

hey there. sorry that you ran into this, but good news! I already have a fix and just need to push the proper commits, which I should be able to do today.

slogsdon commented 9 years ago

I should add that if you're looking for a more technical explanation of what's causing the issue, take a look at #69. The fix I have includes the change to HttpRouter and the router generator (the expression plug Plug.Debugger should be use Plug.Debugger).

YellowApple commented 9 years ago

Moving from plug Plug.Debugger to use Plug.Debugger will definitely require #69 to be addressed. Can confirm that ripping out HttpRouter's defoverridable ... does fix the issues that crop up with that (thus revealing sexy purple Railsy error pages instead of ugly compilation errors :) ).

slogsdon commented 9 years ago

Hey @Horx, I just pushed the remaining fixes to correct this issue. Make sure your deps are up to date with their respective Hex versions (sugar should be at 0.4.7 and http_router should be at 0.0.5) and that the plug Plug.Debugger is updated to use Plug.Debugger in your router.

Let me know if you're still running into issues.

horx commented 9 years ago

@slogsdon Yes, U have do it as you said, The error doesn't appear any more.

But question, The Debugger does not show any log in console after I restarted my app, I‘m not familiar with Debugger, should I add some options to the Debugger or something else ?

YellowApple commented 9 years ago

@Horx Debugger is less of a console thing and more of an error page thing. Plug.Debugger is basically Elixir/Plug's equivalent to the fancy error pages that Ruby on Rails (for example) will show you in a development environment, like so:

screen shot 2015-04-17 at 12 56 36

In the above-screenshotted example, my cleverly-named :asdf application throws an error whenever someone tries to access localhost:4000/ohno (which does nothing other than raise "oops"); with Plug.Debugger, the above page is displayed, providing me with immediate debugging information right from the browser. Pretty nifty.

horx commented 9 years ago

@slogsdon @YellowApple I got it . Thanks for your patience.

slogsdon commented 9 years ago

@Horx Great to hear! let us know if you run into any other issues.