better error handling
This commit is contained in:
@@ -117,6 +117,10 @@ func CreateRouter(client *client.Client, username, password string) *mux.Router
|
||||
share, err := client.CreateShare(r.Context(), shareParams.Key)
|
||||
|
||||
if err != nil {
|
||||
if err == types.ErrKeyNotFound {
|
||||
http.Error(w, "The specified key does not exist", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
logrus.Error(err.Error())
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@@ -136,6 +140,10 @@ func CreateRouter(client *client.Client, username, password string) *mux.Router
|
||||
|
||||
err := client.DeleteShare(r.Context(), vars["slug"])
|
||||
if err != nil {
|
||||
if err == types.ErrShareNotFound {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
logrus.Error(err.Error())
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user