Open psimyn opened 7 years ago
Can you explain the purpose of supporting favicons? Since this is a development-only tool, it doesn't seem like that would be useful.
We currently use different coloured favicons for dev vs prod environments. Helps distinguish which window is which when there are many tabs open. This shows production (left), tab with error, and tab with dev favicon. Ideally the one in the middle should be green
Okay, I can see the value in it being obvious whether you are on production 😬. It seems an edge case, but it also seems like an easy thing to add. Perhaps the default icon should be some kind of Better Errors icon.
I just wanted to see my usual favicon for the app so I can find the browser tab, so I did the following to to override the main.erb template in an initializer:
module BetterErrors
# @private
class ErrorPage
class <<self
alias_method :original_template_path, :template_path
end
def self.template_path(template_name)
if template_name == "main"
File.expand_path("../../../lib/better_errors/templates/#{template_name}.erb", __FILE__)
else
original_template_path(template_name)
end
end
end
end
The template I just overrode in place of the favicon (and saved in lib/better_errors/templates/main.erb
):
<!DOCTYPE html>
<html>
<head>
<title><%= exception_type %> at <%= request_path %></title>
<link rel="icon" type="image/png" href="/favicon.png">
</head>
...
we have some pages that use a different favicon (or non .ico icons)
I think custom path might be the way to go, since that favicon caches are super long
Many thanks for such great errors