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

Open
1 of 17 tasks
quinton-ashley opened this issue May 15, 2025 · 0 comments
Open
1 of 17 tasks
Labels

Comments

@quinton-ashley
Copy link
Contributor

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

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.'));
      }
    });

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

No branches or pull requests

1 participant