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:
parent
88e6910e3a
commit
cb27f33e57
1 changed files with 1 additions and 8 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue