Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error logging #6

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions lib/rails-route-checker/loaded_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,29 @@
module RailsRouteChecker
class LoadedApp
def initialize
@app = suppress_output do
app_base_path = Dir.pwd
app_base_path = Dir.pwd
suppress_output do
require_relative "#{app_base_path}/config/boot"
require_relative "#{Dir.pwd}/config/environment"
end

a = Rails.application
a.eager_load!
begin
suppress_output do
require_relative "#{Dir.pwd}/config/environment"
end
rescue Exception => e
puts "Requiring your config/environment.rb file failed."
puts "This means that something raised while trying to start Rails."
puts ""
puts e.backtrace
raise(e)
end

suppress_output do
@app = Rails.application
@app.eager_load!
attempt_to_load_default_controllers
a.reload_routes!
@app.reload_routes!
Rails::Engine.subclasses.each(&:eager_load!)

a
end
end

Expand All @@ -25,7 +36,7 @@ def routes
reject_route?(r)
end.uniq

return @routes unless @app.config.respond_to?(:assets)
return @routes unless app.config.respond_to?(:assets)

use_spec = defined?(ActionDispatch::Journey::Route) || defined?(Journey::Route)
@routes.reject do |route|
Expand Down