mirror of
https://github.com/iconify/iconify.git
synced 2025-01-06 07:20:40 +00:00
Do not spam log with errors
This commit is contained in:
parent
de037e43e0
commit
220190d8fe
@ -112,17 +112,24 @@ function loadedNewIcons(provider: string, prefix: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
// Storage for errors for loadNewIcons(). Used to avoid spamming log with identical errors.
|
||||
const errorsCache: Record<string, number> = Object.create(null);
|
||||
|
||||
/**
|
||||
* Load icons
|
||||
*/
|
||||
function loadNewIcons(provider: string, prefix: string, icons: string[]): void {
|
||||
function err(): void {
|
||||
console.error(
|
||||
'Unable to retrieve icons for "' +
|
||||
(provider === '' ? '' : '@' + provider + ':') +
|
||||
prefix +
|
||||
'" because API is not configured properly.'
|
||||
);
|
||||
const key = (provider === '' ? '' : '@' + provider + ':') + prefix;
|
||||
const time = Math.floor(Date.now() / 60000); // log once in a minute
|
||||
if (errorsCache[key] < time) {
|
||||
errorsCache[key] = time;
|
||||
console.error(
|
||||
'Unable to retrieve icons for "' +
|
||||
key +
|
||||
'" because API is not configured properly.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Create nested objects if needed
|
||||
|
Loading…
Reference in New Issue
Block a user