mirror of
https://github.com/goharbor/harbor.git
synced 2024-09-29 05:47:31 +02:00
Fix go gas issue for chartserver (#5522)
Add the error handling to fix go gas issue "Error unhandled"
This commit is contained in:
parent
0f519c9dc9
commit
6ed80a370d
@ -154,7 +154,12 @@ func getTheTwoCharts(chartVersions helm_repo.ChartVersions) (latestChart *helm_r
|
||||
if latestChart == nil {
|
||||
latestChart = chartVersion
|
||||
} else {
|
||||
lVersion, _ := semver.NewVersion(latestChart.Version)
|
||||
lVersion, err := semver.NewVersion(latestChart.Version)
|
||||
if err != nil {
|
||||
//ignore it, just logged
|
||||
hlog.Warningf("Malformed semversion %s for the chart %s", latestChart.Version, chartVersion.Name)
|
||||
continue
|
||||
}
|
||||
if lVersion.LessThan(currentV) {
|
||||
latestChart = chartVersion
|
||||
}
|
||||
|
@ -18,8 +18,10 @@ const (
|
||||
func WriteError(w http.ResponseWriter, code int, err error) {
|
||||
errorObj := make(map[string]string)
|
||||
errorObj["error"] = err.Error()
|
||||
errorContent, _ := json.Marshal(errorObj)
|
||||
|
||||
errorContent, errorMarshal := json.Marshal(errorObj)
|
||||
if errorMarshal != nil {
|
||||
errorContent = []byte(err.Error())
|
||||
}
|
||||
w.WriteHeader(code)
|
||||
w.Write(errorContent)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user