ax(mining): replace prose method comments with usage example in errors.go

Seven MiningError method comments restated the function signature verbatim
(AX principle 2 violation). Deleted all seven and replaced NewMiningError's
comment with a concrete call-site example per the RFC rule: if a comment
restates what the type signature already says, delete it.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 07:38:00 +01:00
parent 88e6910e3a
commit cb27f33e57
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -38,7 +38,6 @@ type MiningError struct {
Cause error // Underlying error
}
// Error implements the error interface
func (e *MiningError) Error() string {
if e.Cause != nil {
return fmt.Sprintf("%s: %s (%v)", e.Code, e.Message, e.Cause)
@ -46,35 +45,29 @@ func (e *MiningError) Error() string {
return fmt.Sprintf("%s: %s", e.Code, e.Message)
}
// Unwrap returns the underlying error
func (e *MiningError) Unwrap() error {
return e.Cause
}
// WithCause adds an underlying error
func (e *MiningError) WithCause(err error) *MiningError {
e.Cause = err
return e
}
// WithDetails adds technical details
func (e *MiningError) WithDetails(details string) *MiningError {
e.Details = details
return e
}
// WithSuggestion adds a suggestion for the user
func (e *MiningError) WithSuggestion(suggestion string) *MiningError {
e.Suggestion = suggestion
return e
}
// IsRetryable returns whether the error is retryable
func (e *MiningError) IsRetryable() bool {
return e.Retryable
}
// StatusCode returns the HTTP status code for this error
func (e *MiningError) StatusCode() int {
if e.HTTPStatus == 0 {
return http.StatusInternalServerError
@ -82,7 +75,7 @@ func (e *MiningError) StatusCode() int {
return e.HTTPStatus
}
// NewMiningError creates a new MiningError
// NewMiningError("START_FAILED", "failed to start xmrig").WithCause(err)
func NewMiningError(code, message string) *MiningError {
return &MiningError{
Code: code,