From f3035333fb2963524da1668819d741ec024eb2e4 Mon Sep 17 00:00:00 2001 From: Baptiste Fontaine Date: Wed, 14 Oct 2015 14:42:34 +0200 Subject: [PATCH] FormulaValidationError: include full_name Closes Homebrew/homebrew#44946. Signed-off-by: Baptiste Fontaine --- Library/Homebrew/exceptions.rb | 7 ++++--- Library/Homebrew/formula.rb | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 38bb9bf6b7..957fc42b90 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -23,11 +23,12 @@ class NoSuchKegError < RuntimeError end class FormulaValidationError < StandardError - attr_reader :attr + attr_reader :attr, :formula - def initialize(attr, value) + def initialize(formula, attr, value) @attr = attr - super "invalid attribute: #{attr} (#{value.inspect})" + @formula = formula + super "invalid attribute for formula '#{formula}': #{attr} (#{value.inspect})" end end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 9377dfe77a..2802132655 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -182,17 +182,17 @@ class Formula def validate_attributes! if name.nil? || name.empty? || name =~ /\s/ - raise FormulaValidationError.new(:name, name) + raise FormulaValidationError.new(full_name, :name, name) end url = active_spec.url if url.nil? || url.empty? || url =~ /\s/ - raise FormulaValidationError.new(:url, url) + raise FormulaValidationError.new(full_name, :url, url) end val = version.respond_to?(:to_str) ? version.to_str : version if val.nil? || val.empty? || val =~ /\s/ - raise FormulaValidationError.new(:version, val) + raise FormulaValidationError.new(full_name, :version, val) end end