intridea/grape — pull request #705 by dspaeth-faber (2014-08-01 13:28:57+00:00)
Title: error messages can now be presented

This PR is a proposal to present error messages like started to discuss [here](https://github.com/tim-vandecasteele/grape-swagger/pull/110).
It will be possible to do some thing like this:

```ruby

module API
module Entities
class Error < Grape::Entity
expose :error, documentation: { type: 'string', required: true }
expose :code, documentation: { type: 'integer', required: true }
expose :detail, documentation: { type: 'string', required: true }
expose :href, documentation: { type: 'url', required: true }
expose :rel, documentation: { type: 'string', required: true }
expose :time, documentation: { type: 'datetime', required: true }

def rel
'self'
end

def href
options[:env]['api.endpoint'].request.url
end

def time
Time.now.utc
end
end
end
end

error!({ error: 'Not Found',
detail: "Some more information",
with: API::Entities::Error
}, 404)

```

This PR requires the upcomming version of `grape-entity` .