Skip to content

Commit

Permalink
Cut to the point in exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspth committed Dec 14, 2023
1 parent 7aad146 commit eca45bd
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def account_load_and_authorize_resource(model, options, old_options = {})
namespace.pop
retry
else
raise "Oh no, it looks like your call to 'account_load_and_authorize_resource' is broken. We tried #{tried.join(" and ")}, but didn't find a valid class name."
raise "Your 'account_load_and_authorize_resource' is broken. We tried #{tried.join(" and ")}, but didn't find a valid class name."
end
end

Expand All @@ -81,7 +81,7 @@ def account_load_and_authorize_resource(model, options, old_options = {})
# reflect on the belongs_to association of the child model to figure out the class names of the parents.
association = model_class_name.constantize.reflect_on_association(through_as_symbol)
unless association
raise "Oh no, it looks like your call to 'account_load_and_authorize_resource' is broken. Tried to reflect on the `#{through_as_symbol}` association of #{model_class_name}, but didn't find one."
raise "Your 'account_load_and_authorize_resource' is broken. Tried to reflect on the `#{through_as_symbol}` association of #{model_class_name}, but didn't find one."
end

through_class_name = association.klass.name
Expand All @@ -90,7 +90,7 @@ def account_load_and_authorize_resource(model, options, old_options = {})
through << through_class_name.constantize
through_class_names << through_class_name
rescue NameError
raise "Oh no, it looks like your call to 'account_load_and_authorize_resource' is broken. We tried to load `#{through_class_name}}` (the class name defined for the `#{through_as_symbol}` association), but couldn't find it."
raise "Your 'account_load_and_authorize_resource' is broken. We tried to load `#{through_class_name}}` (the class name defined for the `#{through_as_symbol}` association), but couldn't find it."
end
end

Expand Down

0 comments on commit eca45bd

Please sign in to comment.