Skip to content

Warn via FES when bezierOrder() receives a value other than 2 or 3 - #9136

Open
harshiltewari2004 wants to merge 1 commit into
processing:mainfrom
harshiltewari2004:bezier-order-fes-warning
Open

Warn via FES when bezierOrder() receives a value other than 2 or 3#9136
harshiltewari2004 wants to merge 1 commit into
processing:mainfrom
harshiltewari2004:bezier-order-fes-warning

Conversation

@harshiltewari2004

Copy link
Copy Markdown
Contributor

Resolves #9079

Changes

bezierOrder() is documented as accepting 2 or 3 but validated nothing, so
out-of-range values reached the renderers and failed differently in each:
2D drew nothing, WebGL silently reinterpreted the shape as a quadratic, and
bezierOrder(1) threw a TypeError from inside p5.

fn.bezierOrder now emits a non-blocking FES warning when the order isn't
2 or 3. Renderer behaviour is unchanged — this only adds a message.

Per @davepagurek's preference on the issue, the check reads
p5.disableFriendlyErrors first, so a sketch with FES turned off does no
further work. order !== undefined is checked next so the getter form
(bezierOrder() with no argument) doesn't warn.

Non-numeric and non-integer values ('3', 2.5, null) also warn, since
they fail the same comparison.

The order-1 TypeError still occurs after the warning; the warning names
bezierOrder first, so the user sees the cause before the crash.

PR Checklist

  • npm run lint passes
  • [Inline reference] is included / updated
  • [Unit tests] are included / updated

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]: bezierOrder() accepts values outside its documented range, and 2D and WebGL then fail differently and silently

1 participant