ax(mining): remove ErrCodeInternal alias in favour of canonical ErrCodeInternalError
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:
parent
9261820ab2
commit
ba2e68a685
3 changed files with 5 additions and 6 deletions
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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"})
|
||||
|
|
|
|||
|
|
@ -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"})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue