Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error! method with Grape Entity and Multiple errors #793

Open
pragmaticivan opened this issue Oct 28, 2014 · 1 comment
Open

error! method with Grape Entity and Multiple errors #793

pragmaticivan opened this issue Oct 28, 2014 · 1 comment
Labels

Comments

@pragmaticivan
Copy link
Contributor

On the current implementation we're using with: inside the Hash. By the way, on the documentation the current Grape Entity for API::Error needs a code: to work.

error!({ message: 'Unauthorized', with: API::Error }, 408)

So, what about create a third optional param? something like that:

error!({ message: 'Unauthorized', code: 408 }, 408, with: API::Error)

By the way, how we can create multiple errors and group all?
ex:

{
    "errors": [
        {
            "message": "Sorry, that page does not exist",
            "code": 34
        },
        {
            "message": "Sorry, that page does not exist 2",
            "code": 25
        }
    ]
}
@dblock
Copy link
Member

dblock commented Oct 28, 2014

I am not clear of what the third optional parameter would accomplish.

Can you please make a PR for the documentation mistake?

It doesn't look like we support presenting multiple errors, but you can definitely write a handler (via rescue_from) that transforms any of the input (the first parameter) into anything you want (an array of errors).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants