Skip to content

Commit 107caad

Browse files
committed
tapdb: always wrap errors
Fixes #808. This fixes an issue with errors not being wrapped correctly in some places. That lead to the error not being recognized as a Postgres serialization error, which meant the re-try mechanism wouldn't take over.
1 parent 7c3a8d4 commit 107caad

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

tapdb/asset_minting.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,10 +1096,11 @@ func (a *AssetMintingStore) CommitSignedGenesisTx(ctx context.Context,
10961096
AnchorUtxoID: sqlInt64(utxoID),
10971097
})
10981098
if err != nil {
1099-
return fmt.Errorf("unable to anchor pending assets: %w", err)
1099+
return fmt.Errorf("unable to anchor pending assets: %w",
1100+
err)
11001101
}
11011102

1102-
// Next, we'll anchor the genesis point to point to the chain
1103+
// Next, we'll anchor the genesis point-to-point to the chain
11031104
// transaction we inserted above.
11041105
if err := q.AnchorGenesisPoint(ctx, GenesisPointAnchor{
11051106
PrevOut: genesisOutpoint,

tapdb/asset_minting_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func TestCommitMintingBatchSeedlings(t *testing.T) {
244244
mintingBatch := tapgarden.RandSeedlingMintingBatch(t, numSeedlings)
245245
addRandGroupToBatch(t, assetStore, ctx, mintingBatch.Seedlings)
246246
err := assetStore.CommitMintingBatch(ctx, mintingBatch)
247-
require.NoError(t, err, "unable to write batch: %v", err)
247+
require.NoError(t, err)
248248

249249
batchKey := mintingBatch.BatchKey.PubKey
250250

@@ -267,11 +267,9 @@ func TestCommitMintingBatchSeedlings(t *testing.T) {
267267
// Pick a random seedling and give it a specific group.
268268
addRandGroupToBatch(t, assetStore, ctx, seedlings)
269269
mintingBatch.Seedlings = mergeMap(mintingBatch.Seedlings, seedlings)
270-
require.NoError(t,
271-
assetStore.AddSeedlingsToBatch(
272-
ctx, batchKey, maps.Values(seedlings)...,
273-
), "unable to write seedlings: %v", err,
274-
)
270+
require.NoError(t, assetStore.AddSeedlingsToBatch(
271+
ctx, batchKey, maps.Values(seedlings)...,
272+
))
275273

276274
// If we read the batch from disk again, then we should have 10 total
277275
// seedlings, and the batch still matches what we wrote to disk.
@@ -1088,7 +1086,7 @@ func TestGroupAnchors(t *testing.T) {
10881086
)
10891087
addMultiAssetGroupToBatch(t, mintingBatch.Seedlings)
10901088
err := assetStore.CommitMintingBatch(ctx, mintingBatch)
1091-
require.NoError(t, err, "unable to write batch: %v", err)
1089+
require.NoError(t, err)
10921090

10931091
batchKey := mintingBatch.BatchKey.PubKey
10941092

tapdb/multiverse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ func namespaceForProof(proofType universe.ProofType) (string, error) {
538538
return transferMultiverseNS, nil
539539

540540
default:
541-
return "", fmt.Errorf("unknown proof type: %v", int(proofType))
541+
return "", fmt.Errorf("unknown proof type: %d", int(proofType))
542542
}
543543
}
544544

tapdb/sqlutils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func parseCoalesceNumericType[T constraints.Integer](value any) (T, error) {
167167
parsedValue, err := strconv.ParseInt(typedValue, 10, 64)
168168
if err != nil {
169169
return 0, fmt.Errorf("unable to parse value '%v' as "+
170-
"number: %v", value, err)
170+
"number: %w", value, err)
171171
}
172172

173173
return T(parsedValue), nil

0 commit comments

Comments
 (0)