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 <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 09:50:43 +01:00
parent 61c11cc0ee
commit 22d67f94c2
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -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")
}
}