diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-08-01 16:55:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-01 16:55:18 +0200 |
commit | d81a61398d01d839e70e2345da787e7ef89c0832 (patch) | |
tree | a0702c7874ae31b487bb0b87dcce613edc1e53b9 /api4/system.go | |
parent | 1f168263a2ff73ddee1193cccdeea533f6d501fe (diff) | |
download | chat-d81a61398d01d839e70e2345da787e7ef89c0832.tar.gz chat-d81a61398d01d839e70e2345da787e7ef89c0832.tar.bz2 chat-d81a61398d01d839e70e2345da787e7ef89c0832.zip |
Migrate all the api4 to handle errors in idiomatic way (#9143)
Diffstat (limited to 'api4/system.go')
-rw-r--r-- | api4/system.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/api4/system.go b/api4/system.go index 68f998d6d..9177b8940 100644 --- a/api4/system.go +++ b/api4/system.go @@ -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) { |