Skip to content

Commit

Permalink
refactor: use error message on panic
Browse files Browse the repository at this point in the history
  • Loading branch information
stinkymonkeyph committed Aug 6, 2024
1 parent 5d07ef7 commit 3cee8eb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions blockchain/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"log"
"math"

"github.com/stinkymonkeyph/gopher-blocks/constants"
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 3cee8eb

Please sign in to comment.