From b67cc2960929e875021d567cd81930896f29fc2f Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 4 Aug 2015 15:12:41 +0100 Subject: [PATCH] [btree] bad checksum exceptions now mention the block location --- persistent-data/data-structures/btree.tcc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/persistent-data/data-structures/btree.tcc b/persistent-data/data-structures/btree.tcc index 1cbfc61..cd19fc4 100644 --- a/persistent-data/data-structures/btree.tcc +++ b/persistent-data/data-structures/btree.tcc @@ -38,11 +38,17 @@ namespace { node_header const *n = &data->header; crc32c sum(BTREE_CSUM_XOR); sum.append(&n->flags, MD_BLOCK_SIZE - sizeof(uint32_t)); - if (sum.get_sum() != to_cpu(n->csum)) - throw checksum_error("bad checksum in btree node"); + if (sum.get_sum() != to_cpu(n->csum)) { + std::ostringstream out; + out << "bad checksum in btree node (block " << location << ")"; + throw checksum_error(out.str()); + } - if (to_cpu(n->blocknr) != location) - throw checksum_error("bad block nr in btree node"); + if (to_cpu(n->blocknr) != location) { + std::ostringstream out; + out << "bad block nr in btree node (block = " << location << ")"; + throw checksum_error(out.str()); + } } virtual void prepare(void *raw, block_address location) const {