From 9e92c330915884c529394006a3066eab32a20755 Mon Sep 17 00:00:00 2001 From: Thom Shutt Date: Mon, 15 Aug 2022 14:29:10 +0100 Subject: [PATCH] Handle returned errors from Mist auth --- handlers/client.go | 5 ++--- middleware/logging.go | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/handlers/client.go b/handlers/client.go index 119bb8dbc..858d62cf8 100644 --- a/handlers/client.go +++ b/handlers/client.go @@ -83,7 +83,7 @@ func (mc *MistClient) DeleteTrigger(streamName, triggerName string) error { func (mc *MistClient) getCurrentTriggers() (Triggers, error) { c := commandGetTriggers() resp, err := mc.sendCommand(c) - if err != validateAuth(resp, err) { + if err := validateAuth(resp, err); err != nil { return nil, err } @@ -294,7 +294,7 @@ func validateAddTrigger(streamName, triggerName, resp string, err error) error { } func validateDeleteTrigger(streamName, triggerName, resp string, err error) error { - if err != validateAuth(resp, err) { + if err := validateAuth(resp, err); err != nil { return err } @@ -324,7 +324,6 @@ func validateAuth(resp string, err error) error { if err != nil { return err } - r := struct { Authorize map[string]string `json:"authorize"` }{} diff --git a/middleware/logging.go b/middleware/logging.go index c3c317054..8183fc7cf 100644 --- a/middleware/logging.go +++ b/middleware/logging.go @@ -40,7 +40,7 @@ func LogRequest(logger log.Logger) func(httprouter.Handle) httprouter.Handle { defer func() { if err := recover(); err != nil { - errors.WriteHTTPInternalServerError(wrapped, "Something went wrong", nil) + errors.WriteHTTPInternalServerError(wrapped, "Internal Server Error", nil) logger.Log("err", err, "trace", debug.Stack()) } }()