From aae59d54ef604e02732b493a73b464f85f8f1005 Mon Sep 17 00:00:00 2001 From: Doug Davis Date: Wed, 22 Jul 2015 10:18:36 -0700 Subject: [PATCH] Make Error.Error() return the post-arg-substitution Message Missed this during the removal of the args property Signed-off-by: Doug Davis --- docs/api/errcode/errors.go | 2 +- docs/api/errcode/errors_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/api/errcode/errors.go b/docs/api/errcode/errors.go index acdeb022..fdaddbcf 100644 --- a/docs/api/errcode/errors.go +++ b/docs/api/errcode/errors.go @@ -106,7 +106,7 @@ func (e Error) ErrorCode() ErrorCode { func (e Error) Error() string { return fmt.Sprintf("%s: %s", strings.ToLower(strings.Replace(e.Code.String(), "_", " ", -1)), - e.Code.Message()) + e.Message) } // WithDetail will return a new Error, based on the current one, but with diff --git a/docs/api/errcode/errors_test.go b/docs/api/errcode/errors_test.go index 1f0aaf91..27fb1cec 100644 --- a/docs/api/errcode/errors_test.go +++ b/docs/api/errcode/errors_test.go @@ -126,6 +126,11 @@ func TestErrorsManagement(t *testing.T) { t.Fatalf("Wrong msg, got:\n%q\n\nexpected:\n%q", e1.Message, exp1) } + exp1 = "test3: " + exp1 + if e1.Error() != exp1 { + t.Fatalf("Error() didn't return the right string, got:%s\nexpected:%s", e1.Error(), exp1) + } + // Test again with a single value this time errs = Errors{ErrorCodeUnknown} expectedJSON = "{\"errors\":[{\"code\":\"UNKNOWN\",\"message\":\"unknown error\"}]}"