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?
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:
- These messages are not suppressed when
p5.disableFriendlyErrors = true
- They are not translatable via the i18n system
- 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!
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 byp5.disableFriendlyErrors = true. Migrating these messages improves consistency and accessibility for non-English speaking users.Most appropriate sub-area of p5.js?
Feature enhancement details
Several methods in
p5.TypedDictandp5.NumberDictuse rawconsole.log()for error/validation messages instead of the Friendly Error System. This means:p5.disableFriendlyErrors = trueAffected methods and locations in
src/data/p5.TypedDict.js:get(key)${key} does not exist in this Dictionaryset(key, value)Those values dont work for this dictionary type.create(key, value)In order to create a new Dictionary entry you must pass an object or a key, value pairNumberDict.add(key)The key - ${key} does not exist in this dictionary.NumberDict.mult(key)The key - ${key} does not exist in this dictionary.NumberDict.div(key)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:
Expected behavior:
These validation messages should use
p5._friendlyError()so they respectp5.disableFriendlyErrorsand can be translated via the i18n system.Additional context:
This is consistent with ongoing efforts to migrate raw
console.log/console.warncalls 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!