Skip to content

Respect p5.disableFriendlyErrors setting when overriding p5 global variables #7819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 17 tasks
quinton-ashley opened this issue May 15, 2025 · 2 comments · Fixed by #7888
Closed
1 of 17 tasks

Respect p5.disableFriendlyErrors setting when overriding p5 global variables #7819

quinton-ashley opened this issue May 15, 2025 · 2 comments · Fixed by #7888
Labels

Comments

@quinton-ashley
Copy link
Contributor

quinton-ashley commented May 15, 2025

Most appropriate sub-area of p5.js?

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

p5.js version

1.11.7

Web browser and version

Chrome

Operating system

macOS

Steps to reproduce this

This is a regression, the problem does not occur in previous version of p5.

User's p5.disableFriendlyErrors setting should be respected when overriding p5 global variables.

Example:
https://editor.p5js.org/quinton-ashley/sketches/ca-G8kD1O

The if statement requiring that p5.disableFriendlyErrors be false is correct, but this also needs to be checked before printing the error message, since users could set p5.disableFriendlyErrors = true after that.

if (!p5.disableFriendlyErrors && ...) {
  try {
    Object.defineProperty(globalObject, prop, {
      configurable: true,
      enumerable: true,
      get: function get() {
        return value;
      },
      set: function set(newValue) {
        Object.defineProperty(globalObject, prop, {
          configurable: true,
          enumerable: true,
          value: newValue,
          writable: true
        });


        log('You just changed the value of "'.concat(prop, '", which was a p5 function. This could cause problems later if you\'re not careful.'));
      }
    });

// ...
@quinton-ashley
Copy link
Contributor Author

quinton-ashley commented Jun 2, 2025

Seems that no one else is interested in this.

@ksen0 @davepagurek Should I go ahead and submit a PR?

@davepagurek
Copy link
Contributor

Thanks, go ahead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants