ax(mining): replace prose comments in errors.go with usage examples
AX principle 2: comments must show HOW with real values, not restate what the function name already says. All 14 error constructor comments converted from "ErrX creates a Y error" to concrete call-site examples. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
577775cbf8
commit
7cf7e13b51
1 changed files with 14 additions and 16 deletions
|
|
@ -84,9 +84,7 @@ func NewMiningError(code, message string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// Predefined error constructors for common errors
|
||||
|
||||
// ErrMinerNotFound creates a miner not found error
|
||||
// return ErrMinerNotFound("xmrig").WithCause(err)
|
||||
func ErrMinerNotFound(name string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeMinerNotFound,
|
||||
|
|
@ -97,7 +95,7 @@ func ErrMinerNotFound(name string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrMinerExists creates a miner already exists error
|
||||
// return ErrMinerExists("xmrig")
|
||||
func ErrMinerExists(name string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeMinerExists,
|
||||
|
|
@ -108,7 +106,7 @@ func ErrMinerExists(name string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrMinerNotRunning creates a miner not running error
|
||||
// return ErrMinerNotRunning("xmrig")
|
||||
func ErrMinerNotRunning(name string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeMinerNotRunning,
|
||||
|
|
@ -119,7 +117,7 @@ func ErrMinerNotRunning(name string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrInstallFailed creates an installation failed error
|
||||
// return ErrInstallFailed("xmrig").WithCause(err)
|
||||
func ErrInstallFailed(minerType string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeInstallFailed,
|
||||
|
|
@ -130,7 +128,7 @@ func ErrInstallFailed(minerType string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrStartFailed creates a start failed error
|
||||
// return ErrStartFailed("xmrig").WithCause(err)
|
||||
func ErrStartFailed(name string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeStartFailed,
|
||||
|
|
@ -141,7 +139,7 @@ func ErrStartFailed(name string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrStopFailed creates a stop failed error
|
||||
// return ErrStopFailed("xmrig").WithCause(err)
|
||||
func ErrStopFailed(name string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeStopFailed,
|
||||
|
|
@ -152,7 +150,7 @@ func ErrStopFailed(name string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrInvalidConfig creates an invalid configuration error
|
||||
// return ErrInvalidConfig("wallet address is required")
|
||||
func ErrInvalidConfig(reason string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeInvalidConfig,
|
||||
|
|
@ -163,7 +161,7 @@ func ErrInvalidConfig(reason string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrUnsupportedMiner creates an unsupported miner type error
|
||||
// return ErrUnsupportedMiner("nicehash")
|
||||
func ErrUnsupportedMiner(minerType string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeUnsupportedMiner,
|
||||
|
|
@ -174,7 +172,7 @@ func ErrUnsupportedMiner(minerType string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrConnectionFailed creates a connection failed error
|
||||
// return ErrConnectionFailed("pool.minexmr.com:4444").WithCause(err)
|
||||
func ErrConnectionFailed(target string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeConnectionFailed,
|
||||
|
|
@ -185,7 +183,7 @@ func ErrConnectionFailed(target string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrTimeout creates a timeout error
|
||||
// return ErrTimeout("stats poll")
|
||||
func ErrTimeout(operation string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeTimeout,
|
||||
|
|
@ -196,7 +194,7 @@ func ErrTimeout(operation string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrDatabaseError creates a database error
|
||||
// return ErrDatabaseError("save profile")
|
||||
func ErrDatabaseError(operation string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeDatabaseError,
|
||||
|
|
@ -207,7 +205,7 @@ func ErrDatabaseError(operation string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrProfileNotFound creates a profile not found error
|
||||
// return ErrProfileNotFound("default-xmr")
|
||||
func ErrProfileNotFound(id string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeProfileNotFound,
|
||||
|
|
@ -218,7 +216,7 @@ func ErrProfileNotFound(id string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrProfileExists creates a profile already exists error
|
||||
// return ErrProfileExists("default-xmr")
|
||||
func ErrProfileExists(name string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeProfileExists,
|
||||
|
|
@ -229,7 +227,7 @@ func ErrProfileExists(name string) *MiningError {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrInternal creates a generic internal error
|
||||
// return ErrInternal("unexpected nil response from stats API")
|
||||
func ErrInternal(message string) *MiningError {
|
||||
return &MiningError{
|
||||
Code: ErrCodeInternalError,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue