fixed the Friendly Error message issue in p5.js where error stack tra…#8246
fixed the Friendly Error message issue in p5.js where error stack tra…#8246Mario5T wants to merge 2 commits intoprocessing:mainfrom
Conversation
…ces were pointing to the p5.js library code instead of the user's code.
|
🎉 Thanks for opening this pull request! For guidance on contributing, check out our contributor guidelines and other resources for contributors! Thank You! |
|
@perminder-17 plz review it. |
|
Hi, thanks for your work and your patience. #8212 (comment) I just wrote a comment, and could wait for the approvals? |
|
@perminder-17 just asking if the issue is approved to be worked on will my pr be considered? |
Actually, @sahilsharda commented first on the issue. If they still want's to work, I think I should wait for their PR to open. If not, I'll surely review your PR. |
The Problem (Issue #8212)
When using functions like
createVector(10, NaN)orfloat()incorrectly, the Friendly Error message would point to the line in the p5.js library file that executes the error message, rather than the line in the user's sketch that caused the error.This made debugging difficult for users.
Root Cause
In
validate_params.js, the code used a hardcoded stack frame indexparsed[3]to extract the location of the error.This assumed a fixed call stack depth, which didn't account for errors originating from within p5.js library functions.
Typical Stack Trace
_friendlyParamError_friendlyParamErroritself_validateParameterscreateVector,float) ← was pointing hereThe Fix
Modified
validate_params.js(lines 608–672) to:parsed[3]if no user frame is foundThis approach mirrors the logic already used in the
processStack()function infes_core.jsfor handling global errors.Testing
The fix can be tested with the examples from the bug report: