From c690fa4641fea9d6ace1ed2a3ef5d517b9bf8286 Mon Sep 17 00:00:00 2001 From: "Matt T. Proud" Date: Fri, 21 Apr 2017 10:53:56 +0200 Subject: [PATCH] grpc: make ServerOption panic messages more clear. ServerOption panics when fields that have been manually set are subsequently set again. The message verbiage of `X has been set` is unclear since `has been set` without an adverb like `already` does not correctly convey that the fields are set-once and were previously set. At the worst, the original verbiage `X has been set` could imply that the new value would have been acceptable but another error occurred. We discovered this while conducting a code survey for implementing extensible stubs and uniform inbound interception API. --- server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server.go b/server.go index b15f71c6c182..c1f564ec68f8 100644 --- a/server.go +++ b/server.go @@ -192,7 +192,7 @@ func Creds(c credentials.TransportCredentials) ServerOption { func UnaryInterceptor(i UnaryServerInterceptor) ServerOption { return func(o *options) { if o.unaryInt != nil { - panic("The unary server interceptor has been set.") + panic("The unary server interceptor was already set and may not be reset.") } o.unaryInt = i } @@ -203,7 +203,7 @@ func UnaryInterceptor(i UnaryServerInterceptor) ServerOption { func StreamInterceptor(i StreamServerInterceptor) ServerOption { return func(o *options) { if o.streamInt != nil { - panic("The stream server interceptor has been set.") + panic("The stream server interceptor was already set and may not be reset.") } o.streamInt = i } @@ -214,7 +214,7 @@ func StreamInterceptor(i StreamServerInterceptor) ServerOption { func InTapHandle(h tap.ServerInHandle) ServerOption { return func(o *options) { if o.inTapHandle != nil { - panic("The tap handle has been set.") + panic("The tap handle was already set and may not be reset.") } o.inTapHandle = h }