Skip to content

Commit

Permalink
feat: improve error types
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba-4chain committed Nov 6, 2024
1 parent 87e790e commit 7d9b147
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/blocktx/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (
ErrFailedToSubscribeToTopic = errors.New("failed to subscribe to register topic")
ErrFailedToCreateBUMP = errors.New("failed to create new bump for tx hash from merkle tree and index")
ErrFailedToGetStringFromBUMPHex = errors.New("failed to get string from bump for tx hash")
ErrFailedToParseBlockHash = errors.New("failed to parse block hash")
ErrFailedToInsertBlockTransactions = errors.New("failed to insert block transactions")
)

Expand Down Expand Up @@ -701,7 +702,7 @@ func (p *Processor) storeTransactions(ctx context.Context, blockId uint64, block

blockhash, err := chainhash.NewHash(block.Hash)
if err != nil {
return fmt.Errorf("failed to create block hash for block at height %d", block.Height)
return errors.Join(ErrFailedToParseBlockHash, fmt.Errorf("block height: %d", block.Height), err)
}

var totalSize int
Expand All @@ -726,7 +727,7 @@ func (p *Processor) storeTransactions(ctx context.Context, blockId uint64, block

bump, err := bc.NewBUMPFromMerkleTreeAndIndex(block.Height, merkleTree, uint64(txIndex))
if err != nil {
return fmt.Errorf("failed to create new bump for tx hash %s from merkle tree and index at block height %d: %v", hash.String(), block.Height, err)
return errors.Join(ErrFailedToCreateBUMP, fmt.Errorf("tx hash %s, block height: %d", hash.String(), block.Height), err)
}

bumpHex, err := bump.String()
Expand Down

0 comments on commit 7d9b147

Please sign in to comment.