
Better Rails errors - instakill
https://github.com/charliesome/better_errors
======
patio11
An inline REPL? I love you more than I have words, particularly if you can
somehow snag context for it.

~~~
charliesome
The REPL will execute code in the context of the currently selected stack
frame.

------
__david__
I love this!

To get it to work with my mixed Padrino/Sinatra rack app I had to do this in
each app:

    
    
        if PADRINO_ENV == "development"
          set :raise_errors, true
          set :show_exceptions, false
        end
    

and

    
    
        use BetterErrors::Middleware if PADRINO_ENV == "development"
    

in my "config.ru".

I'm not deeply familiar with Padrino or Sinatra and so it took a lot of
experimentation (and source reading) to find the right incantation. But it's
working great now!

~~~
veesahni
another approach, which doesn't require modification of the rackup file:

[https://github.com/padrino/padrino-
recipes/blob/master/plugi...](https://github.com/padrino/padrino-
recipes/blob/master/plugins/better_errors_plugin.rb)

------
richo
What safeguards do you have in place to stop the unweary from sticking this
into production?

While normally I'm a massive advocate of "Just not being retarded", I suspect
a lot of people are going to drop shells as a result of this gem :(

~~~
charliesome
You're right - I've just released 0.0.6 which (among other things) disables
better_errors when running under Rails in production.

~~~
richo
Awesome. Responsive authors ftw!

~~~
jim-greer
Nice, hopefully it can be enabled for people with certain roles, behind VPN,
etc?

------
sirclueless
This was always something of a killer feature for me in Python, and one of the
reasons I use Flask a lot. Good to see Rails support for in-browser debugging,
it's a super convenient workflow to never have to go back to the terminal,
just alt-tab from editor to browser.

~~~
djisjke
Your workflow may be good, I don't mean to judge that.

But is not the rails way to be in the shell, rails console and editor at all
times? Instead of trying things out in the browser you have automated testing
doing that for you?

~~~
mef
Why would you ever want to make a web app without constantly testing it in a
browser?

~~~
te_chris
Because constantly refreshing the page just to check a variable assignment
that could be checked by an automated test is a ridiculous waste of time.

------
minhajuddin
Thank you for this!

I just found an unintended use for this:

I use pry with a `binding.pry` statement to debug my code, Now I can just
`raise 'Something'` to do this instead. One upside of this is that I can
easily navigate through all the frames from the UI and inspect stuff. If I
want to know what env vars are available in some middleware, I can just click
on it in the UI and start inspecting it.

------
stn
It would be awesome to have this in Rails 4 by default.

~~~
instakill
A bit late now, but 4.1 could get a campaign for this.

~~~
steveklabnik
It is not too late to get things into Rails 4. We haven't released a beta yet.

One of the things Rails 4 already features is better error pages, though no
REPL.

~~~
banister
REPL requires
[binding_of_caller](<https://github.com/banister/binding_of_caller>) anyway,
which i doubt rails would include any time soon ;)

~~~
steveklabnik
That's fair. :)

------
mtarnovan
Seems super-useful. Thanks. I see you require binding_of_caller for advanced
features (which exactly are those, btw?). That gem only works on 1.9. Do they
work on 1.8.7 ? Does the gem work on 1.8.7 at all ?

~~~
charliesome
binding_of_caller is required for the REPL and local/instance variable
inspection. 1.8.x is not supported.

------
burke
I've started building this exact same thing so many times, but never had
nearly the follow-through you did. Fantastic job. This has been sorely lacking
for many years, and I'm excited to start using it!

------
DanielKehoe
Very useful! Better_errors is now an option when generating an application
template with the rails_apps_composer gem [1] or the Rails Composer tool [2].

[1] <http://railsapps.github.com/rails_apps_composer/> [2]
<http://railsapps.github.com/rails-composer/>

------
foobar2k
pry-rescue (<https://github.com/ConradIrwin/pry-rescue>) is also worth
checking out for starting a repl when there is a crash.

Bugsnag (<http://bugsnag.com>) is awesome when debugging production errors.

------
shepbook
As a Rails n00b, I can't wait to try this.

------
skeletonjelly
Looks fantastic! Keen to try Ruby/Rails soon, and coming from C#/VS land I
often find that certain tools are missing in my process, this looks like a
great (and in some ways, better) interface to debugging these kind of errors.

------
jbrooksuk
I'm a complete rails newbie. I've added 'better_errors' into my Gemfile,
started my server/also with Pow and yet I see the same errors as before?

~~~
propercoil
go to the root project in the shell, stop rails server if it's running and
type: bundle install

then start the server again: rails server

~~~
uxp
If he is running under Pow, there's no reason to be running 'script/server' or
'rails server'. That's what Pow does for you.

As with nearly all Rack application servers I know of, you can simply restart
the application by creating/updating 'tmp/restart.txt' from your Rails root.
Unix's `touch` command does this nicely. With Pow specifically, you can also
create '~/.pow/restart.txt' (or '~/Library/Application
Support/Pow/Hosts/restart.txt', since it's the same location) and that will
force Pow to reload itself.

~~~
jbrooksuk
I didn't know abut 'restart.txt' that's awesome!

Also, I've tried that and I'm still getting the same old "Action Controller:
Exception..." error. Specifically I have a MySQL error, yet no 'better_errors'
showing.

I've already executed 'bundle install' too.

------
wildchild
Looking good, I am goind to try it right now.

PS: Probably rack-errors would be much better name for this gem.

~~~
djisjke
or cracked-rack, to make it a bit more punny

------
vijaykoogu
thanks alot.... its very useful... <3

------
danmaz74
Only one comment: WOW!

------
mylittlepony
You guys would be amazed if you tried frameworks like Symfony (instead of
discarding PHP for not being beautiful or whatever). It has always had these
features, and in Symfony2 it only got more awesome. You even have a complete
analysis for each request, that you can open with one click:

<https://s3.amazonaws.com/i.imm.io/OvjX.jpeg>

<https://s3.amazonaws.com/i.imm.io/Ovk9.jpeg>

Edit: Being downvoted. Some people just don't like knowing the truth.

~~~
TallboyOne
No offense, but there is no way in hell I would look at that page for hours on
end coding, it looks like it was designed in 3 minutes.

~~~
robryan
Looks to me like a ton of time was put into the design. Don't think this kind
of "it sucks but I am not going to explain why" comment really adds much.

