Skip to content

Commit 501b3d3

Browse files
committed
fix: include client IP in error messages for geo data lookup
1 parent 099d831 commit 501b3d3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default class WorldTimeApi extends WorkerEntrypoint<Bindings> {
7272
const timezone = await ipToTimezone(this.env.DB, clientIp);
7373

7474
if (!timezone) {
75-
throw new Error("Couldn't find geo data for IP");
75+
throw new Error(`Couldn't find geo data for IP ${clientIp}`);
7676
}
7777

7878
const time = getTime(timezone);

src/routes/ip.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ipRouter.on("GET", ["/ip", "ip.txt"], async (c) => {
2020
const timezone = await ipToTimezone(c.env.DB, clientIp);
2121
if (!timezone) {
2222
throw new HTTPException(404, {
23-
message: "Couldn't find geo data for IP",
23+
message: `Couldn't find geo data for IP ${clientIp}`,
2424
});
2525
}
2626

@@ -43,7 +43,7 @@ ipRouter.on("GET", ["/ip/:ipv4", "/ip/:ipv4.txt"], async (c) => {
4343
timezone = await ipToTimezone(c.env.DB, ipv4);
4444
if (!timezone) {
4545
throw new HTTPException(404, {
46-
message: "Couldn't find geo data for IP",
46+
message: `Couldn't find geo data for IP ${ipv4}`,
4747
});
4848
}
4949
} catch (error) {

0 commit comments

Comments
 (0)