ruby-grape / ruby-grape/grape

error! method with Grape Entity and Multiple errors

Open
#793 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discuss!
Dominant language
Ruby
Stars
10k
Forks
1.2k
Avg merge
14h 38m
Merged PRs (30d)
92

Description

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
        }
    ]
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the current error! implementation and the documentation example for API::Error, especially the required code: field. Compare the proposed optional with: argument and grouped errors response with existing behavior; done means the intended API is specified and both cases are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.