grape icon indicating copy to clipboard operation
grape copied to clipboard

NoMethodError: undefined method `serializable_hash' for #<Hash:0x00007fc3ef69c278> when error entity has root

Open NikolayMurha opened this issue 6 years ago • 2 comments

Hello. I try to add error root for errors.

class API::Error < Grape::Entity
  root 'errors', 'error'
  expose :code
  expose :message
end
error!({ message: "Some error", code: 123, with: API::Error }, 400)

When error entity has root element, I have error:

NoMethodError: undefined method `serializable_hash' for #<Hash:0x00007fc3ef69c278>
	/Users/nikolay/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/grape-1.1.0/lib/grape/error_formatter/base.rb:29:in `present'

Because Grape::Entity#represent method can return entity or hash, but Grape::ErrorFormatter::Base#present is not ready for this result, and called to serializable_hash whatever the result.

NikolayMurha avatar Mar 13 '19 14:03 NikolayMurha

@dblock Can I work on this?

sinscary avatar May 15 '19 09:05 sinscary

Go for it @sinscary, no need to ask.

dblock avatar May 15 '19 10:05 dblock