Skip to content

Commit 369f5c8

Browse files
committed
Raise exception if error cannot be built.
1 parent 1659a62 commit 369f5c8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/jsonapi/rails/renderer.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ class ErrorsRenderer
2121
def self.render(errors, options)
2222
errors = [errors] unless errors.is_a?(Array)
2323
errors = errors.flat_map do |error|
24-
if error.is_a?(ActiveModel::Errors)
24+
if error.respond_to?(:as_jsonapi)
25+
error
26+
elsif error.is_a?(ActiveModel::Errors)
2527
ActiveModelErrors.new(error, options[:_reverse_mapping]).to_a
2628
else
27-
error
29+
raise # TODO(lucas): Raise meaningful exception.
2830
end
2931
end
3032

0 commit comments

Comments
 (0)