diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-24 11:22:59 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-24 11:22:59 +0300 |
| commit | 871f7fa2b9a0fd5653adadfc9efb90fcbd2da203 (patch) | |
| tree | 1f9c21649bf437e9ef6678d7037d24617e71d736 /docs/basic-arithmetic.md | |
| parent | d35efdcdde0b6985473684f0b5668950a8477703 (diff) | |
rpn: replace panic with error returns in metric registry lookups
resolveMetric, coolMetric, and baseMetric all panicked when the
metric registry was missing expected entries. panic() violates Go
best practice (no panic except truly unrecoverable) and can crash the
REPL. resolveMetric is called for every arithmetic operation, making
this a high-impact surface.
Change all three functions to return (*Metric, error) instead of
panicking. Propagate errors through all callers:
- operations_metric.go: resolveMetric, coolMetric, baseMetric,
convertToBase, convertFromBase, resultMetricForMul, resultMetricForDiv, Convert
- operations_arithmetic.go: binaryMetricOp, Divide, Modulo
- operations_compare.go: compareValues
- operations_hyper.go: HyperAdd, HyperMultiply, HyperSubtract,
HyperDivide, HyperPower, HyperModulo, hyperLog
- operations_metric_cmd.go: MetricCompatible
Diffstat (limited to 'docs/basic-arithmetic.md')
0 files changed, 0 insertions, 0 deletions
