Skip to content

fix(image): use FES for setFrame validation errors (#8610)#8613

Open
gourijain029-del wants to merge 1 commit intoprocessing:mainfrom
gourijain029-del:fix-8610-image-setframe-fes
Open

fix(image): use FES for setFrame validation errors (#8610)#8613
gourijain029-del wants to merge 1 commit intoprocessing:mainfrom
gourijain029-del:fix-8610-image-setframe-fes

Conversation

@gourijain029-del
Copy link

@gourijain029-del gourijain029-del commented Mar 5, 2026

1. Changes made

Replaced a raw console.log() call inside setFrame() (in src/image/p5.Image.js) with p5._friendlyError(). This guarantees that if a user tries to set a GIF to an invalid frame index, the warning goes through the Friendly Error System and is suppressed properly if p5.disableFriendlyErrors is set to true.

2. Which issue this PR fixes

Fixes #8610

3. Steps to test changes

  • Load a GIF using loadImage().
  • Disable the Friendly Error System (p5.disableFriendlyErrors = true;).
  • Attempt to set an invalid frame, such as gif.setFrame(9999); or gif.setFrame(-1);.
  • Verify nothing is logged due to FES being disabled.
  • Re-enable the FES and run the sketch again to verify the correct friendly error gets logged in the standard red FES format.

Replaced raw console.log with p5._friendlyError when alerting the user about an out-of-range frame index in setFrame. This ensures the warning is properly formatted and respects the p5.disableFriendlyErrors setting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[p5.js 2.0 Bug Report]: p5.Image.setFrame() validation error bypasses Friendly Error System

1 participant