luckyframework / luckyframework/avram
Rescue Lucky::MissingNestedParamError and raise helpful message
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 183
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
If you are trying to create a record using a SaveOperation and pass `params`, but the params are not used, you'll get a `Lucky::MissingNestedParamError`
We should:
* Add a new `Avram::MissingParamKeyError`
* `Lucky::MissingNestedParamError` can inherit from it to customize the message
* Add helpful message to `Avram::MissingParamKeyError`
The message would look something like this:
```
The 'SaveUser' operation looked for params inside the "user" key, but there were none.
Try this...
> If the operation doesn't need HTTP params, don't pass 'params' to the operation
> If you need HTTP params make sure they are nested under a "user" key
> If you want to use a different key, set the param key in 'SaveUser': https://luckyframework.org/guides/database/validating-saving#perma-param-key
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating Lucky::MissingNestedParamError, Avram::SaveOperation, and the handling of nested params. Confirm how the existing error is raised, then add the shared error and inheritance described in the issue. Done means missing or incorrectly nested params produce the specified helpful message, including the operation and param key.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100