mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Only log error on first occurrence of missing substitution (#9096)
A missing substitution for a localized message will now only log an error upon the first occurrence. Further errors are generally not useful.
This commit is contained in:
parent
1582855e28
commit
b7715f6e70
@ -6,6 +6,7 @@ import * as Sentry from '@sentry/browser'
|
||||
|
||||
const warned = {}
|
||||
const missingMessageErrors = {}
|
||||
const missingSubstitutionErrors = {}
|
||||
|
||||
/**
|
||||
* Returns a localized message for the given key
|
||||
@ -55,7 +56,11 @@ export const getMessage = (localeCode, localeMessages, key, substitutions) => {
|
||||
return part
|
||||
}
|
||||
const substituteIndex = Number(subMatch[1]) - 1
|
||||
if (substitutions[substituteIndex] == null) {
|
||||
if (substitutions[substituteIndex] == null && !missingSubstitutionErrors[localeCode]?.[key]) {
|
||||
if (!missingSubstitutionErrors[localeCode]) {
|
||||
missingSubstitutionErrors[localeCode] = {}
|
||||
}
|
||||
missingSubstitutionErrors[localeCode][key] = true
|
||||
const error = new Error(`Insufficient number of substitutions for message: '${phrase}'`)
|
||||
log.error(error)
|
||||
Sentry.captureException(error)
|
||||
|
Loading…
Reference in New Issue
Block a user