From 22d67f94c2a4f170b8a16ba95cb9619979f2ec5a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 09:50:43 +0100 Subject: [PATCH] ax(mining): replace banned errors import with package error constructors in miner.go Stop() and WriteStdin() used errors.New() (banned import) instead of the package's own MiningError constructors. Replaced with ErrMinerNotRunning() and ErrTimeout() which carry structured codes, HTTP status, and retry hints. Co-Authored-By: Charon --- pkg/mining/miner.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/mining/miner.go b/pkg/mining/miner.go index 70872a2..082143d 100644 --- a/pkg/mining/miner.go +++ b/pkg/mining/miner.go @@ -5,7 +5,6 @@ import ( "archive/zip" "bytes" "compress/gzip" - "errors" "fmt" "io" "net/http" @@ -152,7 +151,7 @@ func (b *BaseMiner) Stop() error { if !b.Running || b.cmd == nil { b.mu.Unlock() - return errors.New("miner is not running") + return ErrMinerNotRunning(b.Name) } // Close stdin pipe if open @@ -210,7 +209,7 @@ func (b *BaseMiner) WriteStdin(input string) error { b.mu.RUnlock() if !running || stdinPipe == nil { - return errors.New("miner is not running or stdin not available") + return ErrMinerNotRunning(b.Name) } // Append newline if not present @@ -235,7 +234,7 @@ func (b *BaseMiner) WriteStdin(input string) error { case err := <-done: return err case <-time.After(stdinWriteTimeout): - return errors.New("stdin write timeout: miner may be unresponsive") + return ErrTimeout("stdin write: miner may be unresponsive") } }