ax(mining): remove ErrCodeInternal alias in favour of canonical ErrCodeInternalError
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

Two names for the same constant violates AX Principle 1 (predictable
names over short names). The alias `ErrCodeInternal` is ambiguous and
shorter than the fully-descriptive `ErrCodeInternalError`. Remove the
alias and update all five call sites to use the canonical name.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 17:52:03 +01:00
parent 9261820ab2
commit ba2e68a685
No known key found for this signature in database
GPG key ID: AF404715446AEB41
3 changed files with 5 additions and 6 deletions

View file

@ -24,7 +24,6 @@ const (
ErrCodeProfileNotFound = "PROFILE_NOT_FOUND"
ErrCodeProfileExists = "PROFILE_EXISTS"
ErrCodeInternalError = "INTERNAL_ERROR"
ErrCodeInternal = "INTERNAL_ERROR" // Alias for consistency
)
// e := &MiningError{Code: ErrCodeStartFailed, Message: "failed to start xmrig", HTTPStatus: 500}

View file

@ -275,7 +275,7 @@ func (ns *NodeService) handlePingPeer(c *gin.Context) {
respondWithError(c, http.StatusNotFound, "PEER_NOT_FOUND", "peer not found or not connected", err.Error())
return
}
respondWithError(c, http.StatusInternalServerError, ErrCodeInternal, "ping failed", err.Error())
respondWithError(c, http.StatusInternalServerError, ErrCodeInternalError, "ping failed", err.Error())
return
}
c.JSON(http.StatusOK, gin.H{"rtt_ms": rtt})
@ -319,7 +319,7 @@ func (ns *NodeService) handleDisconnectPeer(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"status": "disconnected"})
return
}
respondWithError(c, http.StatusInternalServerError, ErrCodeInternal, "disconnect failed", err.Error())
respondWithError(c, http.StatusInternalServerError, ErrCodeInternalError, "disconnect failed", err.Error())
return
}
c.JSON(http.StatusOK, gin.H{"status": "disconnected"})

View file

@ -1187,7 +1187,7 @@ func (s *Service) handleCreateProfile(c *gin.Context) {
createdProfile, err := s.ProfileManager.CreateProfile(&profile)
if err != nil {
respondWithError(c, http.StatusInternalServerError, ErrCodeInternal, "failed to create profile", err.Error())
respondWithError(c, http.StatusInternalServerError, ErrCodeInternalError, "failed to create profile", err.Error())
return
}
@ -1238,7 +1238,7 @@ func (s *Service) handleUpdateProfile(c *gin.Context) {
respondWithError(c, http.StatusNotFound, ErrCodeProfileNotFound, "profile not found", err.Error())
return
}
respondWithError(c, http.StatusInternalServerError, ErrCodeInternal, "failed to update profile", err.Error())
respondWithError(c, http.StatusInternalServerError, ErrCodeInternalError, "failed to update profile", err.Error())
return
}
c.JSON(http.StatusOK, profile)
@ -1260,7 +1260,7 @@ func (s *Service) handleDeleteProfile(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"status": "profile deleted"})
return
}
respondWithError(c, http.StatusInternalServerError, ErrCodeInternal, "failed to delete profile", err.Error())
respondWithError(c, http.StatusInternalServerError, ErrCodeInternalError, "failed to delete profile", err.Error())
return
}
c.JSON(http.StatusOK, gin.H{"status": "profile deleted"})