From 537800956a56f479f2f22adc98e51a948643e15b Mon Sep 17 00:00:00 2001 From: Kane York Date: Fri, 15 Sep 2017 16:08:23 -0700 Subject: [PATCH] Extract JSON error instead of re-encoding it --- socketserver/server/commands.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/socketserver/server/commands.go b/socketserver/server/commands.go index ff8a1582..dc400717 100644 --- a/socketserver/server/commands.go +++ b/socketserver/server/commands.go @@ -439,14 +439,6 @@ type bunchSubscriberList struct { Members []bunchSubscriber } -type cacheStatus byte - -const ( - CacheStatusNotFound = iota - CacheStatusFound - CacheStatusExpired -) - var bunchGroup singleflight.Group // C2SHandleBunchedCommand handles C2S Commands such as `get_link`. @@ -465,7 +457,11 @@ func C2SHandleBunchedCommand(conn *websocket.Conn, client *ClientInfo, msg Clien reply.MessageID = msg.MessageID if result.Err != nil { reply.Command = ErrorCommand - reply.Arguments = result.Err.Error() + if efb, ok := result.Err.(ErrForwardedFromBackend); ok { + reply.Arguments = efb.JSONError + } else { + reply.Arguments = result.Err.Error() + } } else { reply.Command = SuccessCommand reply.origArguments = result.Val.(string)