Skip to content

Improve FES error messages for color functions in p5.strands #8914

@LalitNarayanYadav

Description

@LalitNarayanYadav

Increasing access

Clear error messages help beginners debug shader code. The current FES messages for color functions in strands don't mention the specific function name or the invalid value, making it hard to know what went wrong.
The newly added color APIs in p5.strands expose a few cases where Friendly Error System (FES) messages could be more specific and beginner-friendly.

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

Three FES message improvements for strands color functions:

  1. Missing parameter — lerpColor(c, 0.5) (missing second color arg):
    Current: "Function 'mix' has 3 variants which expect 3 arguments, but 2 were provided."
    Suggested: mention lerpColor by name, not the internal mix function

  2. Wrong parameter type — red("blue") or lerpColor(c1, "blue", 0.5):
    Current: "You've tried to construct a scalar or vector type with a non-numeric value: blue"
    Suggested: also name which function was called and which argument was bad

  3. Invalid color string — color('#fv0a'):
    Current: "Error: Invalid color string"
    Suggested: include the invalid string in the message so users know what to fix

Related PR: #8822

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions