@@ -117,7 +117,7 @@ export default class BlockDbRepository implements BlockRepository {
117117 lastHeight = parseInt ( heightStr , 10 ) ;
118118 lastId = parseInt ( idStr , 10 ) ;
119119 if ( isNaN ( lastHeight ) || isNaN ( lastId ) ) {
120- throw new Error ( ' Invalid after cursor' ) ;
120+ throw new Error ( `[ERROR][VALID][VALID_FORMAT] Invalid ' after' cursor:', ${ after } ` ) ;
121121 }
122122 }
123123
@@ -126,7 +126,7 @@ export default class BlockDbRepository implements BlockRepository {
126126 lastHeight = parseInt ( heightStr , 10 ) ;
127127 lastId = parseInt ( idStr , 10 ) ;
128128 if ( isNaN ( lastHeight ) || isNaN ( lastId ) ) {
129- throw new Error ( ' Invalid before cursor' ) ;
129+ throw new Error ( `[ERROR][VALID][VALID_FORMAT] Invalid ' before' cursor:', ${ before } ` ) ;
130130 }
131131 }
132132
@@ -308,7 +308,7 @@ export default class BlockDbRepository implements BlockRepository {
308308 const beforeId = parseInt ( id , 10 ) ;
309309
310310 if ( isNaN ( beforeHeight ) || isNaN ( beforeId ) ) {
311- throw new Error ( ' Invalid before cursor' ) ;
311+ throw new Error ( `[ERROR][VALID][VALID_FORMAT] Invalid ' before' cursor:', ${ before } ` ) ;
312312 }
313313
314314 queryParams . push ( beforeHeight , beforeId ) ;
@@ -322,7 +322,7 @@ export default class BlockDbRepository implements BlockRepository {
322322 const afterId = parseInt ( id , 10 ) ;
323323
324324 if ( isNaN ( afterHeight ) || isNaN ( afterId ) ) {
325- throw new Error ( ' Invalid after cursor' ) ;
325+ throw new Error ( `[ERROR][VALID][VALID_FORMAT] Invalid ' after' cursor:', ${ after } ` ) ;
326326 }
327327 queryParams . push ( afterHeight , afterId ) ;
328328 conditions += `\nAND (b.height, b.id) > ($${ queryParams . length - 1 } , $${ queryParams . length } )` ;
@@ -407,7 +407,9 @@ export default class BlockDbRepository implements BlockRepository {
407407 const [ balanceRow ] = balanceRows ;
408408
409409 if ( ! balanceRow ) {
410- throw new Error ( "Miner didn't exist." ) ;
410+ throw new Error (
411+ `[ERROR][DB][DATA_MISSING] Miner account not found for block ${ hash } on chain ${ chainId } .` ,
412+ ) ;
411413 }
412414
413415 const res = await handleSingleQuery ( {
@@ -609,7 +611,9 @@ export default class BlockDbRepository implements BlockRepository {
609611 ) ;
610612
611613 if ( blockRows . length !== eventIds . length ) {
612- throw new Error ( 'There was an issue fetching blocks for event IDs.' ) ;
614+ throw new Error (
615+ `[ERROR][DB][DATA_CORRUPT] Fetched blocks count (${ blockRows . length } ) does not match event IDs count (${ eventIds . length } ).` ,
616+ ) ;
613617 }
614618
615619 const blockMap = blockRows . reduce (
@@ -660,7 +664,9 @@ export default class BlockDbRepository implements BlockRepository {
660664 ) ;
661665
662666 if ( blockRows . length !== transactionIds . length ) {
663- throw new Error ( 'There was an issue fetching blocks for transaction IDs.' ) ;
667+ throw new Error (
668+ `[ERROR][DB][DATA_CORRUPT] Fetched blocks count (${ blockRows . length } ) does not match transaction IDs count (${ transactionIds . length } ).` ,
669+ ) ;
664670 }
665671
666672 const blockMap = blockRows . reduce (
@@ -709,7 +715,9 @@ export default class BlockDbRepository implements BlockRepository {
709715 ) ;
710716
711717 if ( blockRows . length !== hashes . length ) {
712- throw new Error ( 'There was an issue fetching blocks for transaction IDs.' ) ;
718+ throw new Error (
719+ `[ERROR][DB][DATA_CORRUPT] Fetched blocks count (${ blockRows . length } ) does not match requested hashes count (${ hashes . length } ).` ,
720+ ) ;
713721 }
714722
715723 const blockMap = blockRows . reduce (
0 commit comments