Skip to content

refactor(error): standardize aggregated error handling with multierr#129

Open
kangeunchan wants to merge 2 commits intoaltuslabsxyz:mainfrom
kangeunchan:refactor/error-multierr-standardize
Open

refactor(error): standardize aggregated error handling with multierr#129
kangeunchan wants to merge 2 commits intoaltuslabsxyz:mainfrom
kangeunchan:refactor/error-multierr-standardize

Conversation

@kangeunchan
Copy link
Collaborator

Enhancement Description

Standardize aggregated error handling with go.uber.org/multierr while preserving Go error-chain semantics.

Summary

This PR replaces custom multi-error aggregation in Docker orchestration with multierr.Append and aligns wrapping semantics for better diagnostics.

Previously, custom aggregation reduced consistency:

  • error-chain behavior (errors.Is/As) was weaker across aggregated failures
  • wrapping style varied by failure path
  • rollback/deploy combined failures were harder to inspect consistently

Now error aggregation follows one standard pattern with explicit tests.

What Changed

1) Replaced custom aggregation with multierr

Updated:

  • internal/infrastructure/docker/orchestrator.go

Changes:

  • removed custom multi-error implementation
  • standardized aggregation via multierr.Append

2) Standardized wrapping at failure boundaries

  • preserved causal context using %w
  • ensured deploy and rollback failures compose consistently

3) Added usage guidance

Added:

  • docs/error-handling.md

Guidance covers:

  • %w wrapping conventions
  • multierr aggregation pattern
  • preserving errors.Is/As behavior

4) Tests

Added/updated tests:

  • internal/infrastructure/docker/orchestrator_test.go

Why This Is Needed

This is a correctness and maintainability refactor.
Standardized error chains improve debugging, observability, and tooling compatibility.

Behavior Notes / Regression Impact

No intentional user-facing behavior change.
Error surfaces are more consistent while preserving root causes.

Validation Performed

  • go test ./internal/infrastructure/docker -count=1
  • go test ./...
  • golangci-lint run ./internal/infrastructure/docker/...

Signed-off-by: kangeunchan <kangeunchan080310@gmail.com>
Signed-off-by: kangeunchan <kangeunchan080310@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant