Skip to content

Non Rails frameworks

Robin Daugherty edited this page Feb 27, 2020 · 4 revisions

Frameworks that work

Rack

require "better_errors"

if ENV["RACK_ENV"] == "development"
  use BetterErrors::Middleware
end

Sinatra

Add the following to the top of your Sinatra application:

require "better_errors"

configure :development do
  use BetterErrors::Middleware
  BetterErrors.application_root = __dir__
end

Frameworks with issues

Hanami

A demonstration of how to use Better Errors with Hanami is in phoffer/hanami-better_errors. However, it demonstrates two bugs that keep Better Errors from working.

(One of those issues is with Shotgun, a fix for which is described below.

Middleman

Add the following to config.rb:

require "better_errors"
require "binding_of_caller"

set :show_exceptions, false
configure :development do
  use BetterErrors::Middleware
  BetterErrors.application_root = __dir__
end

There is currently a bug that keeps context information from loading using Middleman.

Shotgun

Shotgun causes every request to load all dependencies, including Better Errors. Better Errors relies on storing the most recent exception in memory, and Shotgun makes this impossible.

The solution is to remove shotgun from your project. One alternative is rerun, which instead restarts the application only when files within the application change.