From ed29b0d1684b7b8be7ee1d0f04f6ecd22c6bb9f0 Mon Sep 17 00:00:00 2001
From: Travis Ralston <travpc@gmail.com>
Date: Wed, 11 Apr 2018 22:28:33 -0600
Subject: [PATCH] Pass the breaker error upwards to the caller

Part of #86
---
 src/github.com/turt2live/matrix-media-repo/api/auth.go     | 1 -
 src/github.com/turt2live/matrix-media-repo/matrix/admin.go | 4 ++--
 src/github.com/turt2live/matrix-media-repo/matrix/auth.go  | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/github.com/turt2live/matrix-media-repo/api/auth.go b/src/github.com/turt2live/matrix-media-repo/api/auth.go
index d8fe4a61..0bca4171 100644
--- a/src/github.com/turt2live/matrix-media-repo/api/auth.go
+++ b/src/github.com/turt2live/matrix-media-repo/api/auth.go
@@ -19,7 +19,6 @@ func AccessTokenRequiredRoute(next func(r *http.Request, log *logrus.Entry, user
 		appserviceUserId := util.GetAppserviceUserIdFromRequest(r)
 		userId, err := matrix.GetUserIdFromToken(r.Context(), r.Host, accessToken, appserviceUserId)
 		if err != nil || userId == "" {
-			log.Error(err)
 			if err != nil && err != matrix.ErrNoToken {
 				log.Error("Error verifying token: ", err)
 				return InternalServerError("Unexpected Error")
diff --git a/src/github.com/turt2live/matrix-media-repo/matrix/admin.go b/src/github.com/turt2live/matrix-media-repo/matrix/admin.go
index b35e063d..8dd9f399 100644
--- a/src/github.com/turt2live/matrix-media-repo/matrix/admin.go
+++ b/src/github.com/turt2live/matrix-media-repo/matrix/admin.go
@@ -13,7 +13,7 @@ func IsUserAdmin(ctx context.Context, serverName string, accessToken string) (bo
 
 	isAdmin := false
 	var replyError error
-	cb.CallContext(ctx, func() error {
+	replyError = cb.CallContext(ctx, func() error {
 		mtxClient, err := gomatrix.NewClient(hs.ClientServerApi, "", accessToken)
 		if err != nil {
 			err, replyError = filterError(err)
@@ -40,7 +40,7 @@ func ListMedia(ctx context.Context, serverName string, accessToken string, roomI
 
 	response := &mediaListResponse{}
 	var replyError error
-	cb.CallContext(ctx, func() error {
+	replyError = cb.CallContext(ctx, func() error {
 		mtxClient, err := gomatrix.NewClient(hs.ClientServerApi, "", accessToken)
 		if err != nil {
 			err, replyError = filterError(err)
diff --git a/src/github.com/turt2live/matrix-media-repo/matrix/auth.go b/src/github.com/turt2live/matrix-media-repo/matrix/auth.go
index c8498b1c..23d495bd 100644
--- a/src/github.com/turt2live/matrix-media-repo/matrix/auth.go
+++ b/src/github.com/turt2live/matrix-media-repo/matrix/auth.go
@@ -19,7 +19,7 @@ func GetUserIdFromToken(ctx context.Context, serverName string, accessToken stri
 
 	userId := ""
 	var replyError error
-	cb.CallContext(ctx, func() error {
+	replyError = cb.CallContext(ctx, func() error {
 		mtxClient, err := gomatrix.NewClient(hs.ClientServerApi, "", accessToken)
 		if err != nil {
 			err, replyError = filterError(err)
-- 
GitLab