@@ -54,10 +54,10 @@ var (
54
54
55
55
// replaceCustomData replaces the custom channel data hex string with the
56
56
// decoded custom channel data in the JSON response.
57
- func replaceCustomData (jsonBytes []byte ) ( []byte , error ) {
57
+ func replaceCustomData (jsonBytes []byte ) []byte {
58
58
// If there's nothing to replace, return the original JSON.
59
59
if ! customDataPattern .Match (jsonBytes ) {
60
- return jsonBytes , nil
60
+ return jsonBytes
61
61
}
62
62
63
63
replacedBytes := customDataPattern .ReplaceAllFunc (
@@ -78,10 +78,12 @@ func replaceCustomData(jsonBytes []byte) ([]byte, error) {
78
78
var buf bytes.Buffer
79
79
err := json .Indent (& buf , replacedBytes , "" , " " )
80
80
if err != nil {
81
- return nil , err
81
+ // If we can't indent the JSON, it likely means the replacement
82
+ // data wasn't correct, so we return the original JSON.
83
+ return jsonBytes
82
84
}
83
85
84
- return buf .Bytes (), nil
86
+ return buf .Bytes ()
85
87
}
86
88
87
89
func getContext () context.Context {
@@ -118,11 +120,7 @@ func printRespJSON(resp proto.Message) {
118
120
return
119
121
}
120
122
121
- jsonBytesReplaced , err := replaceCustomData (jsonBytes )
122
- if err != nil {
123
- fmt .Println ("unable to replace custom data: " , err )
124
- jsonBytesReplaced = jsonBytes
125
- }
123
+ jsonBytesReplaced := replaceCustomData (jsonBytes )
126
124
127
125
fmt .Printf ("%s\n " , jsonBytesReplaced )
128
126
}
0 commit comments