Skip to content

Commit

Permalink
mod - different error codes for tx/history
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Eric Bassett committed Jul 10, 2020
1 parent bea58f9 commit 2c4f0e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/index.ts
Expand Up @@ -177,14 +177,16 @@ const txHistory = async (req: Request, res: Response) => {

if(untilBlockNum.kind === 'error' && untilBlockNum.errMsg !== utils.errMsgs.noValue) {
const msg = `untilBlockNum failed: ${untilBlockNum.errMsg}`;
throw new Error("txHistory: "+msg);
throw new Error("REFERENCE_BEST_BLOCK_MISMATCH");
return;
}
if(afterBlockNum.kind === 'error' && afterBlockNum.errMsg !== utils.errMsgs.noValue) {
const msg = `afterBlockNum failed: ${afterBlockNum.errMsg}`;
throw new Error("tsHistory: "+msg);
throw new Error("REFERENCE_TX_NOT_FOUND");
return;
}
// TODO: we should handle the case where body.after.tx is not in the
// reference block.

const maybeTxs = await askTransactionHistory(pool, limit, body.addresses, afterBlockNum, untilBlockNum);
switch(maybeTxs.kind) {
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/index.ts
Expand Up @@ -22,5 +22,5 @@ export const logErrors = (err:Error, req: Request, res: Response, next: NextFunc
};

export const errorHandler = (err:Error, req: Request, res: Response, next: NextFunction) => {
res.status(500).send({ error: err.message });
res.status(500).send({ error: { response: err.message }});
};

0 comments on commit 2c4f0e8

Please sign in to comment.