Migrate all the api4 to handle errors in idiomatic way (#9143)

Этот коммит содержится в:
Jesús Espino
2018-08-01 16:55:18 +02:00
коммит произвёл GitHub
родитель 1f168263a2
Коммит d81a61398d
17 изменённых файлов: 430 добавлений и 393 удалений

Просмотреть файл

@@ -341,20 +341,21 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) {
buf := bytes.NewBuffer(nil)
io.Copy(buf, file)
if license, err := c.App.SaveLicense(buf.Bytes()); err != nil {
if err.Id == model.EXPIRED_LICENSE_ERROR {
license, appErr := c.App.SaveLicense(buf.Bytes())
if appErr != nil {
if appErr.Id == model.EXPIRED_LICENSE_ERROR {
c.LogAudit("failed - expired or non-started license")
} else if err.Id == model.INVALID_LICENSE_ERROR {
} else if appErr.Id == model.INVALID_LICENSE_ERROR {
c.LogAudit("failed - invalid license")
} else {
c.LogAudit("failed - unable to save license")
}
c.Err = err
c.Err = appErr
return
} else {
c.LogAudit("success")
w.Write([]byte(license.ToJson()))
}
c.LogAudit("success")
w.Write([]byte(license.ToJson()))
}
func removeLicense(c *Context, w http.ResponseWriter, r *http.Request) {