processing/p5.js

canvas doesn't load, no error thrown when invalid parameter passed to `textWrap()`

rbstrachan opened this issue · 3 comments

Most appropriate sub-area of p5.js?

  • Core/Environment/Rendering
  • Typography
  • Friendly errors

p5.js version

1.9.2

Web browser and version

Firefox 125.0.2

Operating system

Linux Ubuntu 22.04 LTS

Steps to reproduce this

Steps

  1. Create a new project.
  2. Pass an invalid parameter, such as a number or string, to textWrap() in setup().

Snippet

function setup() {
  createCanvas(400, 400);
  textWrap(50);
}

Notes

When I first tried to use textWrap(), I wrongly assumed it took the maximum width, in pixels, of the text before wrapping occurred, so I did something like textWrap(width * 2 / 3);. The canvas disappeared and no error was given. I believe I've seen this behavior before with other methods but I can't remember which ones.

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you!

It seems that the textWrap() function (src/typography/attributes.js#L541) does do a simple if then check to throw an error, but doesn't use p5._validateParameters().