P5.js: Wrapper function error messages refer to their core function name

Created on 30 Sep 2019  Â·  6Comments  Â·  Source: processing/p5.js

Nature of issue?

  • Found a bug

Details about the bug:

  • Web browser and version: any
  • Operating System: macOS 10.13.4
  • Steps to reproduce this bug:

Something like

function setup() {
  circle();
}

or

function setup() {
  square();
}

respectively result in error messages like: p5.js says: ellipse() was expecting at least 3 arguments (…) (or rect() respectively), so they don't refer to the name of the wrapping function that is actually used (circle(), square()) but to the underlying function that is called instead. Much to the confusion of my students in their first class today. 😃 It would be nice, if the name of the actual function would be used instead.

bug friendly-errors

All 6 comments

thanks for reporting! this should go in the core p5.js repository. i'll transfer it there ✨

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

Thanks @trych this seems like a problem that probably exists in many places. Definitely don't want to create this type of confusion!

Just briefly glancing around it seems that this might need some thought. We could add p5._validateParameters('circle', arguments); to this line. But then both

p5.js says: circle() was expecting at least 3 arguments ... 

&&

p5.js says: ellipse() was expecting at least 3 arguments ...

would be logged.

Solving this might require shuffling the way that _validateParameters() is called and/or the way it works internally. I can look around more later but if anyone has thoughts in the meantime they are very welcome. I could be overlooking an easy fix.

@stalgiag is right about the duplicate logs. you likely have to parse the stack trace here https://github.com/processing/p5.js/blob/main/src/core/error_helpers.js#L552 and add more meaningful text in the error message if there is a call below func in the stack trace

hi @trych! i have a fix for the circle and square instances of this! they will have their own parameter validation and message. are there other methods you've seen this problem with that i should take a look at?

@outofambit Great, thanks! All the other shape commands seem to work fine, so I think we're good. :)

Was this page helpful?
0 / 5 - 0 ratings