diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-23 21:51:31 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-23 21:51:31 +0200 |
| commit | 3e4d79f5eeacd8ea5a18af28ece514795f3bbded (patch) | |
| tree | 2d482ebced5278c884054cec825d625a265ea081 /internal/rpn/operations.go | |
| parent | 505ae7aa4efe582e6c65098ec09ff1db18f43ffc (diff) | |
internal/rpn: fix error handling, variable name validation, and locking issues
- Use error wrapping with ErrVariableNotFound for consistent error checking
- Add isValidVariableName() for comprehensive variable name validation
- Fix race condition in ClearVariables() by clearing instead of replacing map
- Eliminate double-locking in FormatVariables() with internal helper function
Diffstat (limited to 'internal/rpn/operations.go')
| -rw-r--r-- | internal/rpn/operations.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/internal/rpn/operations.go b/internal/rpn/operations.go index 1ebd78b..cab77db 100644 --- a/internal/rpn/operations.go +++ b/internal/rpn/operations.go @@ -419,7 +419,7 @@ func (o *Operations) UseVariable(stack *Stack, name string) error { val, exists := o.vars.GetVariable(name) if !exists { - return fmt.Errorf("undefined variable: %s", name) + return fmt.Errorf("%w: %s", ErrVariableNotFound, name) } stack.Push(val) @@ -435,7 +435,7 @@ func (o *Operations) DeleteVariable(name string) error { deleted := o.vars.DeleteVariable(name) if !deleted { - return fmt.Errorf("undefined variable: %s", name) + return fmt.Errorf("%w: %s", ErrVariableNotFound, name) } return nil } |
