Skip to content
This repository was archived by the owner on Jul 16, 2020. It is now read-only.

Commit 728a215

Browse files
author
Leoswaldo Macias
committed
ciao-controller: make returnErrorCode func variadic
returnErrorCode function receives a message string which it will return with this design the message needed to be formatted before calling the function, making the function variadic for the message will enable the function to be call with the messages to be formatted in the function, so we don't have to preformat every time we call it. The returnErrorCode func will now build the message string in the format specified with the args passed to it as values. Signed-off-by: Leoswaldo Macias <[email protected]>
1 parent c3a8a64 commit 728a215

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ciao-controller/compute.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,12 @@ func instanceToServer(context *controller, instance *types.Instance) (payloads.S
453453
}
454454

455455
// returnErrorCode returns error codes for the http call
456-
func returnErrorCode(w http.ResponseWriter, httpError int, message string) {
456+
func returnErrorCode(w http.ResponseWriter, httpError int, messageFormat string, messageArgs ...interface{}) {
457457
var returnCode payloads.HTTPReturnErrorCode
458458
returnCode.Error.Code = httpError
459459
returnCode.Error.Name = http.StatusText(returnCode.Error.Code)
460-
returnCode.Error.Message = message
460+
461+
returnCode.Error.Message = fmt.Sprintf(messageFormat, messageArgs...)
461462

462463
b, err := json.Marshal(returnCode)
463464
if err != nil {

0 commit comments

Comments
 (0)