Created
July 26, 2017 11:38
-
-
Save aaronmcadam/12c20394f88605e853653e1916717ecb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kokoro | |
class ErrorsController < ApplicationController | |
skip_before_action :guards_for_user | |
def not_found | |
Rails.logger.info(not_found_message) | |
path = env["ORIGINAL_FULLPATH"] | |
render( | |
template: "kokoro/errors/not_found", | |
locals: { path: path }, | |
status: 404 | |
) | |
end | |
def error | |
Rails.logger.error(error_message) | |
render(template: "kokoro/errors/error", status: 500, formats: :html) | |
end | |
private | |
def not_found_message | |
message("Not Found") | |
end | |
def error_message | |
message("System Error. User ID: #{current_user.id}") | |
end | |
def message(type) | |
exception = env["action_dispatch.exception"] | |
full_path = env["ORIGINAL_FULLPATH"] | |
"#{type}: '#{full_path}'. "\ | |
"#{exception.class} (#{exception.message}) error was raised." | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
404 routes to
#not_found
, 50x routes to#error