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!
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.
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?
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.
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 ?
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!
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].
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.
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.
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.
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:
This isn't a specific draw to PHP, for example several Python frameworks have some flavor of 'debug toolbar' which does the same. Nice feature if you do use PHP otherwise, though.
The downvotes may be partly because you are using an article about a specific Ruby project as a jumping off point to promote another language, which is slightly obnoxious - make a thread for your new PHP stuff you are interested in, people who are happily using Ruby don't need to be exhorted to use other languages for no specific reason
Does it have an inline context aware repl? It saves me the trouble of putting the breakpoint, running the request again, and removing the breakpoint.
> You even have a complete analysis for each request, that you can open with one click:
Do I get the queries generated for the request and time it took for them? And the time it took for the templates to be rendered?
Werkzeug debugger and flask-debug-toolbar are my baseline for debugging toolbars. They don't try to be everything and give me everything I need.
> You guys would be amazed if you tried frameworks like Symfony (instead of discarding PHP for not being beautiful or whatever)
Helpful exception logs and inline repls are one of n things to take into consideration. This alone isn't going to buy any converts.
At the end of day, they are convenience tools. It's not like I can't debug code or profile db requests without them. If I can get an inline context aware repl, superb. If not, good old breakpoints are mighty fine.
The PHP ECOSYSTEM has some awesome stuff, I completely agree. A lot of the companies with a decent amount of tech brand behind them in the HN community still use it a lot.
In saying that, the PHP LANGUAGE has some pretty glaring and terrifying warts, a fact that Rasmus doesn't try to hide.
Guys, just because you do Rails doesn't mean you can't get to know other frameworks too.
I came to Rails from Symfony and there are definitely things I miss. Rails is way better overall, but there are loads of little things that were fantastically useful.
The downvotes are overzealous in this case. A comment like this offers useful additional info/context about other languages that offer comparable capability, since many developers keep more than one type of screwdriver in their toolbox (or at least like to stay abreast of how their screwdriver du jour compares with other tools).
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.