From 3b7801751a144e5ee0534e8d2e7fae2061bbfc32 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 19 Aug 2015 00:39:03 -0700 Subject: [PATCH] Separate out Cause and full Debug --- print-structs.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/print-structs.go b/print-structs.go index c03efbda..d62602ba 100644 --- a/print-structs.go +++ b/print-structs.go @@ -38,18 +38,19 @@ func (e ErrorMessage) String() string { return e.Cause.Error() } if !globalDebugFlag { - errorMessageBytes, err := json.MarshalIndent(e.Cause, "", "\t") - if err != nil { - panic(err) - } - return console.JSON(string(errorMessageBytes) + "\n") - } else { - errorMessageBytes, err := json.MarshalIndent(e, "", "\t") + errorMessageBytes, err := json.MarshalIndent(struct { + Cause error `json:"cause"` + }{Cause: e.Cause}, "", "\t") if err != nil { panic(err) } return console.JSON(string(errorMessageBytes) + "\n") } + errorMessageBytes, err := json.MarshalIndent(e, "", "\t") + if err != nil { + panic(err) + } + return console.JSON(string(errorMessageBytes) + "\n") } // DiffJSONMessage json container for diff messages @@ -193,7 +194,8 @@ func (s ShareMessage) String() string { if err != nil { panic(err) } - // json encoding escapes ampersand into its unicode character which is not usable directly for share and fails with cloud storage. + // json encoding escapes ampersand into its unicode character which is not usable directly for share + // and fails with cloud storage. convert them back so that they are usable shareMessageBytes = bytes.Replace(shareMessageBytes, []byte("\\u0026"), []byte("&"), -1) return console.JSON("%s\n", string(shareMessageBytes)) }