From 1d66e34dc8f9524e72139dba6eb0ec87cf059fc6 Mon Sep 17 00:00:00 2001 From: ValarDragon Date: Sat, 9 Jun 2018 16:22:52 -0700 Subject: [PATCH] Bech32: Wrap error messages --- bech32/bech32.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bech32/bech32.go b/bech32/bech32.go index 3c778309c..a4db86d5f 100644 --- a/bech32/bech32.go +++ b/bech32/bech32.go @@ -2,13 +2,14 @@ package bech32 import ( "github.com/btcsuite/btcutil/bech32" + "github.com/pkg/errors" ) //ConvertAndEncode converts from a base64 encoded byte string to base32 encoded byte string and then to bech32 func ConvertAndEncode(hrp string, data []byte) (string, error) { converted, err := bech32.ConvertBits(data, 8, 5, true) if err != nil { - return "", err + return "", errors.Wrap(err, "encoding bech32 failed") } return bech32.Encode(hrp, converted) @@ -18,11 +19,11 @@ func ConvertAndEncode(hrp string, data []byte) (string, error) { func DecodeAndConvert(bech string) (string, []byte, error) { hrp, data, err := bech32.Decode(bech) if err != nil { - return "", nil, err + return "", nil, errors.Wrap(err, "decoding bech32 failed") } converted, err := bech32.ConvertBits(data, 5, 8, false) if err != nil { - return "", nil, err + return "", nil, errors.Wrap(err, "decoding bech32 failed") } return hrp, converted, nil }