Commit d6c9788
Changed files (14)
app
config
initializers
app/controllers/api/errors_controller.rb
@@ -0,0 +1,12 @@
+class API::ErrorsController < Api::Controller
+ include Gaffe::Errors
+ skip_before_action :authenticate!
+
+ layout false
+
+ def show
+ output = { error: @rescue_response }
+ output.merge! exception: @exception.inspect, backtrace: @exception.backtrace.first(10) if Rails.env.development? || Rails.env.test?
+ render json: output, status: @status_code
+ end
+end
app/controllers/errors_controller.rb
@@ -0,0 +1,8 @@
+class ErrorsController < PublicController
+ include Gaffe::Errors
+ layout "public"
+
+ def show
+ render @rescue_response, status: @status_code
+ end
+end
app/views/errors/bad_request.html.erb
@@ -0,0 +1,7 @@
+<div class="container">
+ <div class="columns">
+ <div class="column is-8 is-offset-2 has-text-centered">
+ <h1 class="title">Bad Request</h1>
+ </div>
+ </div>
+</div>
app/views/errors/forbidden.html.erb
@@ -0,0 +1,7 @@
+<div class="container">
+ <div class="columns">
+ <div class="column is-8 is-offset-2 has-text-centered">
+ <h1 class="title">Forbidden</h1>
+ </div>
+ </div>
+</div>
app/views/errors/internal_server_error.html.erb
@@ -0,0 +1,7 @@
+<div class="container">
+ <div class="columns">
+ <div class="column is-8 is-offset-2 has-text-centered">
+ <h1 class="title">Internal Server Error</h1>
+ </div>
+ </div>
+</div>
app/views/errors/method_not_allowed.html.erb
@@ -0,0 +1,7 @@
+<div class="container">
+ <div class="columns">
+ <div class="column is-8 is-offset-2 has-text-centered">
+ <h1 class="title">Method Not Allowed</h1>
+ </div>
+ </div>
+</div>
app/views/errors/not_acceptable.html.erb
@@ -0,0 +1,7 @@
+<div class="container">
+ <div class="columns">
+ <div class="column is-8 is-offset-2 has-text-centered">
+ <h1 class="title">Not Acceptable</h1>
+ </div>
+ </div>
+</div>
app/views/errors/not_found.html.erb
@@ -0,0 +1,7 @@
+<div class="container">
+ <div class="columns">
+ <div class="column is-8 is-offset-2 has-text-centered">
+ <h1 class="title">Not Found</h1>
+ </div>
+ </div>
+</div>
app/views/errors/not_implemented.html.erb
@@ -0,0 +1,7 @@
+<div class="container">
+ <div class="columns">
+ <div class="column is-8 is-offset-2 has-text-centered">
+ <h1 class="title">Not Implemented</h1>
+ </div>
+ </div>
+</div>
app/views/errors/unprocessable_entity.html.erb
@@ -0,0 +1,7 @@
+<div class="container">
+ <div class="columns">
+ <div class="column is-8 is-offset-2 has-text-centered">
+ <h1 class="title">Unprocessable Entity</h1>
+ </div>
+ </div>
+</div>
config/initializers/gaffe.rb
@@ -0,0 +1,7 @@
+Gaffe.configure do |config|
+ config.errors_controller = {
+ %r[^/api/] => 'Api::ErrorsController',
+ %r[^/] => 'ErrorsController',
+ }
+end
+Gaffe.enable!
Gemfile
@@ -25,6 +25,7 @@ source "https://rubygems.org" do
gem "flipper-redis"
gem "font-awesome-rails"
gem "foreman", group: :development
+ gem "gaffe"
gem "geocoder"
gem "geokit-rails"
gem "griddler"
Gemfile.lock
@@ -164,6 +164,8 @@ GEM
railties (>= 3.2, < 5.1)
foreman (0.82.0)
thor (~> 0.19.1)
+ gaffe (1.2.0)
+ rails (>= 4.0.0)
geocoder (1.3.7)
geokit (1.10.0)
geokit-rails (2.1.0)
@@ -455,6 +457,7 @@ DEPENDENCIES
flipper-redis!
font-awesome-rails!
foreman!
+ gaffe!
geocoder!
geokit-rails!
griddler!