-
Notifications
You must be signed in to change notification settings - Fork 26
Description
In situations where the Octopus Server returns an error, the core.APIErrorChecker function is run to validate the response.
This function has a hardcoded error template string format of "octopus deploy api returned an error on endpoint %s - %s", urlPath, octopusDeployError.Errors
Note: octopusDeployError.Errors is a []string, representing a JSON array that the server sent us in the error response.
This results in a caller, (e.g. the CLI) receiving a string such as the following:
octopus deploy api returned an error on endpoint /api/Spaces-1/releases/create/v1 - [Release '5.0.2' already exists for this project. Please use a different version, or look at using a mask to auto-increment the number.]
This is not particularly friendly for end-user display. The brute force option would be to regex or string-split to pull out the contents inside the [], however this is incredibly brittle.
My preferred option would be to have the APIErrorChecker return a richer error struct, which contained the server-sent strings in an array that could be accessed by the caller. This would enable the CLI to simply print the server-sent error: Release '5.0.2' already exists for this project. Please use a different version, or look at using a mask to auto-increment the number.