Skip to content

Commit

Permalink
Return GoCardless rate limit information on error (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd authored Dec 6, 2024
1 parent df958eb commit 645958b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/app-gocardless/app-gocardless.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,19 @@ app.post(
});
}
} catch (error) {
const headers = error.details?.response?.headers ?? {};

const rateLimitHeaders = Object.fromEntries(
Object.entries(headers).filter(([key]) =>
key.startsWith('http_x_ratelimit'),
),
);

const sendErrorResponse = (data) =>
res.send({ status: 'ok', data: { ...data, details: error.details } });
res.send({
status: 'ok',
data: { ...data, details: error.details, rateLimitHeaders },
});

switch (true) {
case error instanceof RequisitionNotLinked:
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/509.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [matt-fidd]
---

Add more logging for GoCardless rate limit information

0 comments on commit 645958b

Please sign in to comment.