Skip to content

Commit 990b4dd

Browse files
roy-dydxmergify[bot]
authored andcommitted
Fix uncaught postgres error (#2635)
(cherry picked from commit 1b03acb)
1 parent 87a43cd commit 990b4dd

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

indexer/services/comlink/src/lib/compliance-and-geo-check.ts

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import express from 'express';
1414
import { matchedData } from 'express-validator';
1515

1616
import { AddressRequest, BlockedCode } from '../types';
17-
import { create4xxResponse } from './helpers';
17+
import {
18+
create4xxResponse,
19+
handleInternalServerError,
20+
} from './helpers';
1821
import { getIpAddr, isIndexerIp } from './utils';
1922

2023
/**
@@ -46,24 +49,34 @@ export async function complianceAndGeoCheck(
4649
}
4750

4851
if (address !== undefined) {
49-
const updatedStatus: ComplianceStatusFromDatabase[] = await ComplianceStatusTable.findAll(
50-
{ address: [address] },
51-
[],
52-
{ readReplica: true },
53-
);
54-
if (updatedStatus.length > 0) {
55-
if (updatedStatus[0].status === ComplianceStatus.CLOSE_ONLY ||
56-
updatedStatus[0].status === ComplianceStatus.FIRST_STRIKE_CLOSE_ONLY
57-
) {
58-
return next();
59-
} else if (updatedStatus[0].status === ComplianceStatus.BLOCKED) {
60-
return create4xxResponse(
61-
res,
62-
INDEXER_COMPLIANCE_BLOCKED_PAYLOAD,
63-
403,
64-
{ code: BlockedCode.COMPLIANCE_BLOCKED },
65-
);
52+
try {
53+
const updatedStatus: ComplianceStatusFromDatabase[] = await ComplianceStatusTable.findAll(
54+
{ address: [address] },
55+
[],
56+
{ readReplica: true },
57+
);
58+
if (updatedStatus.length > 0) {
59+
if (updatedStatus[0].status === ComplianceStatus.CLOSE_ONLY ||
60+
updatedStatus[0].status === ComplianceStatus.FIRST_STRIKE_CLOSE_ONLY
61+
) {
62+
return next();
63+
} else if (updatedStatus[0].status === ComplianceStatus.BLOCKED) {
64+
return create4xxResponse(
65+
res,
66+
INDEXER_COMPLIANCE_BLOCKED_PAYLOAD,
67+
403,
68+
{ code: BlockedCode.COMPLIANCE_BLOCKED },
69+
);
70+
}
6671
}
72+
} catch (error) {
73+
return handleInternalServerError(
74+
'complianceAndGeoCheck',
75+
'complianceAndGeoCheck error',
76+
error,
77+
req,
78+
res,
79+
);
6780
}
6881
}
6982

indexer/services/comlink/src/lib/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function handleControllerError(
8282
);
8383
}
8484

85-
function handleInternalServerError(
85+
export function handleInternalServerError(
8686
at: string,
8787
message: string,
8888
error: Error,

0 commit comments

Comments
 (0)