This is a consolidation effort, avoiding usage of naked strings in codebase. Whenever possible use constants which can be repurposed elsewhere. This also fixes `goconst ./...` reported issues.
Showing the changes to cmd/api-errors.go (1 of 79 files). Show all
Unified · Split
| @@ -675,15 +675,11 @@ func getAPIError(code APIErrorCode) APIError { · 674 unmodified lines | ||
| 675 | 675 | // getErrorResponse gets in standard error and resource value and |
| 676 | 676 | // provides a encodable populated response values |
| 677 | 677 | func getAPIErrorResponse(err APIError, resource string) APIErrorResponse { |
| 678 | − var data = APIErrorResponse{} | |
| 679 | − data.Code = err.Code | |
| 680 | − data.Message = err.Description | |
| 681 | − if resource != "" { | |
| 682 | − data.Resource = resource | |
| 678 | + return APIErrorResponse{ | |
| 679 | + Code: err.Code, | |
| 680 | + Message: err.Description, | |
| 681 | + Resource: resource, | |
| 682 | + RequestID: "3L137", | |
| 683 | + HostID: "3L137", | |
| 683 | 684 | } |
| 684 | − // TODO implement this in future | |
| 685 | − data.RequestID = "3L137" | |
| 686 | − data.HostID = "3L137" | |
| 687 | − | |
| 688 | − return data | |
| 689 | 685 | } |