ruby-grape / ruby-grape/grape

Grape::Exceptions::ValidationErrors context

Open
#574 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

How I can get context of error?

For example: I want know entry point (request_path, route, etc) or resource where the validation exception was handled?

Right now looks like I can do that using custom exception_handler and doing stuff like that:

rescue_from Grape::Exceptions::ValidationErrors do |e|
  App::Exceptions::ValidationHandler.new(e, self.env["api.endpoint"].env["REQUEST_PATH"], self.env["api.endpoint"].env["REQUEST_METHOD"]).produce
end

Is that only way that exist right now? What about adding context to errors? (I can send a PR for that)

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 by tracing Grape::Exceptions::ValidationErrors and the custom rescue_from handler shown in the issue, including the api.endpoint environment values used for REQUEST_PATH and REQUEST_METHOD. Determine the intended context scope and document what request or resource information should be available when validation errors are handled.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.