[p5.js 2.0+ Bug Report]: Some Vector friendly errors don't work correctly
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:
- Run the snippet below. It has an error; the first param should be a vector.
- The expected output is a friendly error message "The v1 parameter should be of type Array or p5.Vector"
- 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.
@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
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.
I am working on this! CodeDay tasks assigned this to me and one other person. Can you please assign me this issue?
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!
Thanks for letting me know @CarlyAThomas !
Hi @ksen0 I saw the Code-Day contributor is no more working on this issue could u re-assign this to me ??
thanks ...
@ksen0 now can I work on this?
@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 I will work on this
thanks ....
hii @ksen0 , I can reproduce the same error as mentioned , just wanted to ask if someone is still working on the issue
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 ...