Skip to content

Instantly share code, notes, and snippets.

@aaronmcadam
Created July 26, 2017 11:38
Show Gist options
  • Save aaronmcadam/12c20394f88605e853653e1916717ecb to your computer and use it in GitHub Desktop.
Save aaronmcadam/12c20394f88605e853653e1916717ecb to your computer and use it in GitHub Desktop.
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
@aaronmcadam
Copy link
Author

404 routes to #not_found, 50x routes to #error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment