Skip to content

[p5.js 2.0 Bug Report]: p5.TypedDict error messages bypass Friendly Error System (6 raw console.log calls) #8607

@MASTERsj01

Description

@MASTERsj01

Increasing access

The Friendly Error System (FES) exists to provide beginner-friendly, translatable error messages. When parts of the codebase bypass FES with raw console.log(), those messages cannot be translated via i18n and are not suppressed by p5.disableFriendlyErrors = true. Migrating these messages improves consistency and accessibility for non-English speaking users.

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)

Feature enhancement details

Several methods in p5.TypedDict and p5.NumberDict use raw console.log() for error/validation messages instead of the Friendly Error System. This means:

  1. These messages are not suppressed when p5.disableFriendlyErrors = true
  2. They are not translatable via the i18n system
  3. They are inconsistent with the rest of the codebase's error handling approach

Affected methods and locations in src/data/p5.TypedDict.js:

Method Line Message
get(key) L167 ${key} does not exist in this Dictionary
set(key, value) L194 Those values dont work for this dictionary type.
create(key, value) L238 In order to create a new Dictionary entry you must pass an object or a key, value pair
NumberDict.add(key) L462 The key - ${key} does not exist in this dictionary.
NumberDict.mult(key) L512 The key - ${key} does not exist in this dictionary.
NumberDict.div(key) L539 The key - ${key} does not exist in this dictionary.

(Note: print() at L315 intentionally logs key-value pairs as user output — that should remain as-is.)

Example of current code:

// get() at line 163
get(key) {
  if (this.data.hasOwnProperty(key)) {
    return this.data[key];
  } else {
    console.log(`${key} does not exist in this Dictionary`);
  }
}

Expected behavior:

These validation messages should use p5._friendlyError() so they respect p5.disableFriendlyErrors and can be translated via the i18n system.

Additional context:

This is consistent with ongoing efforts to migrate raw console.log/console.warn calls to FES across the codebase (e.g., similar patterns were addressed in WebGL modules and other areas).

I'd be happy to work on this if it gets approved!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions