From a8996933bf4cd59ec49955247b0fdac5ccd52200 Mon Sep 17 00:00:00 2001 From: rumikk Date: Fri, 7 Jan 2022 10:00:05 +0300 Subject: [PATCH] ToJson fix error handling (#16) --- convertor/convertor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/convertor/convertor.go b/convertor/convertor.go index ead1405..9d03bbe 100644 --- a/convertor/convertor.go +++ b/convertor/convertor.go @@ -79,10 +79,10 @@ func ToString(value interface{}) string { func ToJson(value interface{}) (string, error) { res, err := json.Marshal(value) if err != nil { - res = []byte("") + return "", err } - return string(res), err + return string(res), nil } // ToFloat convert value to a float64, if input is not a float return 0.0 and error