From 896e5cb7632a4ce883c295334bce82a3724c4861 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 30 Jan 2021 14:19:37 -0600 Subject: [PATCH] Add BetterErrors gem. --- Gemfile | 2 ++ Gemfile.lock | 9 +++++++++ app/controllers/application_controller.rb | 2 +- config/environments/development.rb | 3 +++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index b455e6a86..27c6cf9fb 100644 --- a/Gemfile +++ b/Gemfile @@ -65,6 +65,8 @@ group :development do gem 'stackprof' gem 'flamegraph' gem 'memory_profiler' + gem 'better_errors' + gem 'binding_of_caller' end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 256e845df..01bff0c6f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -115,6 +115,12 @@ GEM aws-sigv4 (1.2.2) aws-eventstream (~> 1, >= 1.0.2) bcrypt (3.1.16) + better_errors (2.9.1) + coderay (>= 1.0.0) + erubi (>= 1.0.0) + rack (>= 0.9.0) + binding_of_caller (1.0.0) + debug_inspector (>= 0.0.1) bootsnap (1.5.1) msgpack (~> 1.0) builder (3.2.4) @@ -153,6 +159,7 @@ GEM crass (1.0.6) daemons (1.3.1) dante (0.2.0) + debug_inspector (1.0.0) delayed_job (4.1.9) activesupport (>= 3.0, < 6.2) delayed_job_active_record (4.1.5) @@ -415,6 +422,8 @@ DEPENDENCIES addressable aws-sdk-sqs (~> 1) bcrypt + better_errors + binding_of_caller bootsnap builder capistrano (~> 3.10) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 27a4b3889..f5ede6a8d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -120,7 +120,7 @@ class ApplicationController < ActionController::Base when PG::ConnectionBad render_error_page(503, exception, message: "The database is unavailable. Try again later.") else - raise exception if Danbooru.config.debug_mode + raise exception if !Rails.env.production? || Danbooru.config.debug_mode render_error_page(500, exception) end end diff --git a/config/environments/development.rb b/config/environments/development.rb index f0d62dc0c..e80d22833 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -63,4 +63,7 @@ Rails.application.configure do # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true + + BetterErrors::Middleware.allow_ip!(IPAddr.new("0.0.0.0/0")) + BetterErrors::Middleware.allow_ip!(IPAddr.new("::/0")) end