p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

[p5.js 2.0+ Bug Report]: Some Vector friendly errors don't work correctly

Open sidwellr opened this issue 5 months ago • 11 comments

Most appropriate sub-area of p5.js?

  • [ ] Accessibility
  • [ ] Color
  • [ ] Core/Environment/Rendering
  • [ ] Data
  • [ ] DOM
  • [ ] Events
  • [ ] Image
  • [ ] IO
  • [x] Math
  • [ ] Typography
  • [ ] Utilities
  • [ ] WebGL
  • [ ] WebGPU
  • [ ] p5.strands
  • [ ] Build process
  • [ ] Unit testing
  • [ ] Internationalization
  • [ ] Friendly errors
  • [ ] Other (specify if possible)

p5.js version

2.3.0

Web browser and version

Brave 1.90.122

Operating system

Linux Mint 22.1

Steps to reproduce this

Steps:

  1. Run the snippet below. It has an error; the first param should be a vector.
  2. The expected output is a friendly error message "The v1 parameter should be of type Array or p5.Vector"
  3. Instead, it gives an error "TypeError: this._friendlyError is not a function"

Snippet:

function setup() {
  print(p5.Vector.equals(1, createVector(1, 2)));
}

Discussion

Friendly errors for vectors seem to work fine for instance methods like setValue(), but not for static methods like p5.Vector.equals.

sidwellr avatar Jun 16 '26 15:06 sidwellr

@ksen0 @davepagurek @perminder-17 cause is that static methods like p5.Vector.equals() call this._friendlyError where this is the Vector constructor, but _friendlyError is only set on Vector.prototype, not on Vector itself. The fix is to also set Vector._friendlyError = p5._friendlyError in the registration function, plus override Vector.friendlyErrorsDisabled to check p5.disableFriendlyErrors since the static version always returns true. Can I be assigned? if ok I will go with the pr

BHARATH0153 avatar Jun 17 '26 13:06 BHARATH0153

This issue has been added to the CodeDay tasks! If it's not complete in a few weeks, it can be assigned back to you @BHARATH0153 when you're back. If CodeDay students are working on it, you're also welcome to help review and test their solution. Thanks everyone in advance for your understnading.

ksen0 avatar Jun 29 '26 13:06 ksen0

I am working on this! CodeDay tasks assigned this to me and one other person. Can you please assign me this issue?

CarlyAThomas avatar Jun 29 '26 18:06 CarlyAThomas

Hi @ksen0, I wanted to let you know that I've been reassigned by my CodeDay-CTI mentor to a different project, so I'll be stepping away from this issue. I've unassigned myself so it can be reassigned to another contributor. Thanks!

CarlyAThomas avatar Jul 02 '26 20:07 CarlyAThomas

Thanks for letting me know @CarlyAThomas !

ksen0 avatar Jul 03 '26 07:07 ksen0

Hi @ksen0 I saw the Code-Day contributor is no more working on this issue could u re-assign this to me ??

thanks ...

Ayush4958 avatar Jul 18 '26 08:07 Ayush4958

@ksen0 now can I work on this?

BHARATH0153 avatar Jul 20 '26 17:07 BHARATH0153

@Ayush4958 it's your if you still want it! Thanks

If Ayush doesn't reply by end of day on July 27, you can work on it after that @BHARATH0153

Thanks for your interest and understanding!

ksen0 avatar Jul 20 '26 17:07 ksen0

@ksen0 I will work on this

thanks ....

Ayush4958 avatar Jul 20 '26 18:07 Ayush4958

hii @ksen0 , I can reproduce the same error as mentioned , just wanted to ask if someone is still working on the issue

rizzhal avatar Aug 11 '26 16:08 rizzhal

Hi @rizzhal I had already raise PR Resolving this which is under review rn You can look upto other opened issues which are not currently under progress

Thanks ...

Ayush4958 avatar Aug 11 '26 16:08 Ayush4958