Commit 51673b90 authored by Kelvin Fichter's avatar Kelvin Fichter

fix(cmn): have BaseService throw on missing options

Fixes a bug where BaseServiceV2 was not properly throwing when options
were missing.
parent 44c5ce37
---
'@eth-optimism/common-ts': patch
---
Have BaseServiceV2 throw when options are undefined
......@@ -218,6 +218,16 @@ export abstract class BaseServiceV2<
return acc
}, {}) as TOptions
// Make sure all options are defined.
for (const [optionName, optionSpec] of Object.entries(params.optionsSpec)) {
if (
optionSpec.default === undefined &&
this.options[optionName] === undefined
) {
throw new Error(`missing required option: ${optionName}`)
}
}
// Create the metrics objects.
this.metrics = Object.keys(params.metricsSpec || {}).reduce((acc, key) => {
const spec = params.metricsSpec[key]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment