diff options
| author | mo khan <mo@mokhan.ca> | 2017-02-26 13:21:30 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2017-02-26 13:21:30 -0700 |
| commit | d6c9788771f7dcbd96408130bc4e10e6497bee60 (patch) | |
| tree | 1a511d58856b2792b0ccb782a06df7a4e2663c21 /app | |
| parent | 5780e2d66fa27dd40bf5d3b581c68285c3199213 (diff) | |
add custom error pages.
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/api/errors_controller.rb | 12 | ||||
| -rw-r--r-- | app/controllers/errors_controller.rb | 8 | ||||
| -rw-r--r-- | app/views/errors/bad_request.html.erb | 7 | ||||
| -rw-r--r-- | app/views/errors/forbidden.html.erb | 7 | ||||
| -rw-r--r-- | app/views/errors/internal_server_error.html.erb | 7 | ||||
| -rw-r--r-- | app/views/errors/method_not_allowed.html.erb | 7 | ||||
| -rw-r--r-- | app/views/errors/not_acceptable.html.erb | 7 | ||||
| -rw-r--r-- | app/views/errors/not_found.html.erb | 7 | ||||
| -rw-r--r-- | app/views/errors/not_implemented.html.erb | 7 | ||||
| -rw-r--r-- | app/views/errors/unauthorized.html.erb | 7 | ||||
| -rw-r--r-- | app/views/errors/unprocessable_entity.html.erb | 7 |
11 files changed, 83 insertions, 0 deletions
diff --git a/app/controllers/api/errors_controller.rb b/app/controllers/api/errors_controller.rb new file mode 100644 index 0000000..09a7f16 --- /dev/null +++ b/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 diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb new file mode 100644 index 0000000..d6eabf5 --- /dev/null +++ b/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 diff --git a/app/views/errors/bad_request.html.erb b/app/views/errors/bad_request.html.erb new file mode 100644 index 0000000..f4b9423 --- /dev/null +++ b/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> diff --git a/app/views/errors/forbidden.html.erb b/app/views/errors/forbidden.html.erb new file mode 100644 index 0000000..d026b2e --- /dev/null +++ b/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> diff --git a/app/views/errors/internal_server_error.html.erb b/app/views/errors/internal_server_error.html.erb new file mode 100644 index 0000000..26d9119 --- /dev/null +++ b/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> diff --git a/app/views/errors/method_not_allowed.html.erb b/app/views/errors/method_not_allowed.html.erb new file mode 100644 index 0000000..1d94399 --- /dev/null +++ b/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> diff --git a/app/views/errors/not_acceptable.html.erb b/app/views/errors/not_acceptable.html.erb new file mode 100644 index 0000000..0f48aae --- /dev/null +++ b/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> diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb new file mode 100644 index 0000000..ad56df9 --- /dev/null +++ b/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> diff --git a/app/views/errors/not_implemented.html.erb b/app/views/errors/not_implemented.html.erb new file mode 100644 index 0000000..9bcc68e --- /dev/null +++ b/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> diff --git a/app/views/errors/unauthorized.html.erb b/app/views/errors/unauthorized.html.erb new file mode 100644 index 0000000..0c2d218 --- /dev/null +++ b/app/views/errors/unauthorized.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">Unauthorized</h1> + </div> + </div> +</div> diff --git a/app/views/errors/unprocessable_entity.html.erb b/app/views/errors/unprocessable_entity.html.erb new file mode 100644 index 0000000..5b11640 --- /dev/null +++ b/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> |
