From 3cee8eb01dceb68ea49e205b8abe3a787e2a87a2 Mon Sep 17 00:00:00 2001 From: stinkymonkeyph Date: Wed, 7 Aug 2024 01:06:51 +0800 Subject: [PATCH] refactor: use error message on panic --- blockchain/transaction.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/blockchain/transaction.go b/blockchain/transaction.go index 44dd7fd..872014f 100644 --- a/blockchain/transaction.go +++ b/blockchain/transaction.go @@ -4,6 +4,7 @@ import ( "crypto/sha256" "encoding/hex" "encoding/json" + "log" "math" "github.com/stinkymonkeyph/gopher-blocks/constants" @@ -32,7 +33,7 @@ func (t *Transaction) ToJSON() string { tb, err := json.Marshal(t) if err != nil { - panic("Something went wrong while serializing transaction object") + log.Panicf(err.Error()) } return string(tb) @@ -56,7 +57,7 @@ func (t *Transaction) Hash() string { ts, err := json.Marshal(t) if err != nil { - panic("Something went wrong while serializing transaction object") + log.Panicf(err.Error()) } sum := sha256.Sum256(ts)