[p5.strands] Better error messages when you return the wrong type in a hook
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 24k
- Forks
- 3.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 25
Description
Increasing access
If I call getWorldInputs(() => [1, 2, 3, 4]), returning a vec4 instead of an inputs struct, I get: You have returned a undefined from getWorldInputs when a Vertex was expected.
I did not return undefined, I returned a vec4! So that could already be clearer. Also although the data type expected here is Vertex, this is not really something that is understandable to users. They should either be modifying and returning the inputs that are passed in to the function, or as of the next release, just modifying the inputs and returning nothing at all for cases where a struct is passed in as a param and the same struct is expected to be returned.
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
Feature enhancement details
In other cases where a different return is expected, the type name is still meaningless to users, we'd need to tell them what properties to expect on the object.
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 tracing the getWorldInputs hook and the existing error path for incorrect return values in the WebGL area. Review how expected return types are currently reported; done means users receive meaningful guidance about the returned value and the properties or input structure expected in each affected case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100