File tree Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,16 @@ class InvalidQuery < Error; end
8686
8787 class UnsupportedKeyType < Error ; end
8888
89- class UnknownAttribute < Error ; end
89+ class UnknownAttribute < Error
90+ attr_reader :model_class , :attribute_name
91+
92+ def initialize ( model_class , attribute_name )
93+ super ( "Attribute #{ attribute_name } does not exist in #{ model_class } " )
94+
95+ @model_class = model_class
96+ @attribute_name = attribute_name
97+ end
98+ end
9099
91100 class SubclassNotFound < Error ; end
92101
Original file line number Diff line number Diff line change @@ -291,7 +291,7 @@ def write_attribute(name, value)
291291 old_value = read_attribute ( name )
292292
293293 unless attribute_is_present_on_model? ( name )
294- raise Dynamoid ::Errors ::UnknownAttribute , "Attribute #{ name } is not part of the model"
294+ raise Dynamoid ::Errors ::UnknownAttribute . new ( self . class , name )
295295 end
296296
297297 if association = @associations [ name ]
Original file line number Diff line number Diff line change @@ -7,9 +7,9 @@ module UpdateValidations
77 def self . validate_attributes_exist ( model_class , attributes )
88 model_attributes = model_class . attributes . keys
99
10- attributes . each_key do |attr_name |
11- unless model_attributes . include? ( attr_name )
12- raise Dynamoid ::Errors ::UnknownAttribute , "Attribute #{ attr_name } does not exist in #{ model_class } "
10+ attributes . each_key do |name |
11+ unless model_attributes . include? ( name )
12+ raise Dynamoid ::Errors ::UnknownAttribute . new ( model_class , name )
1313 end
1414 end
1515 end
You can’t perform that action at this time.
0 commit comments