Skip to content

[p5.strands] Better error messages when you return the wrong type in a hook #8444

@davepagurek

Description

@davepagurek

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions