From 01bc3dd7524f3c92419cf17c8d9e300f0a1c2e32 Mon Sep 17 00:00:00 2001 From: keyan Date: Wed, 20 Dec 2023 20:05:09 -0600 Subject: [PATCH] catch query errors --- api/resolvers/ofac.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/api/resolvers/ofac.js b/api/resolvers/ofac.js index a418ebdd..1b24e540 100644 --- a/api/resolvers/ofac.js +++ b/api/resolvers/ofac.js @@ -15,10 +15,15 @@ export async function gOFACYourself ({ models, headers = {}, ip }) { ip ||= xRealIp || xForwardedFor?.split(',')?.[0] if (!ip) return false - const countries = await models.$queryRaw` - SELECT * FROM "OFAC" WHERE iprange("startIP","endIP") >>= ${ip}::ipaddress` + try { + const countries = await models.$queryRaw` + SELECT * FROM "OFAC" WHERE iprange("startIP","endIP") >>= ${ip}::ipaddress` - if (countries.length === 0) return false + if (countries.length === 0) return false - return countries[0].country + return countries[0].country + } catch (e) { + console.error('gOFACYourself', e) + return false + } }