Skip to content

Commit

Permalink
Override prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Feb 20, 2022
1 parent 8f37315 commit a3f77d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/config/normalize/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ export const normalizeConfig = async function (
{ UserErrorType = UserError, ...opts },
) {
try {
return await normalizeConfigProps(config, definitions, opts)
return await normalizeConfigProps(config, definitions, {
...opts,
prefix: PREFIX,
})
} catch (error) {
throw handleConfigError(error, UserErrorType)
}
}

const PREFIX = 'Configuration property'

// Distinguish user validation errors from system errors
const handleConfigError = function (error, UserErrorType) {
return error.validation ? wrapError(error, '', UserErrorType) : error
Expand Down
7 changes: 6 additions & 1 deletion src/config/plugin/lib/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ export const safeNormalizeConfig = async function (
{ UserErrorType, SystemErrorType, ...opts },
) {
try {
return await normalizeConfigProps(config, definitions, opts)
return await normalizeConfigProps(config, definitions, {
...opts,
prefix: PREFIX,
})
} catch (error) {
const ErrorType = error.validation ? UserErrorType : SystemErrorType
throw wrapError(error, '', ErrorType)
}
}

const PREFIX = 'Configuration property'

0 comments on commit a3f77d7

Please sign in to comment.