Skip to content

Commit

Permalink
Log reponse body when fetching Lizzy fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhincore committed Sep 20, 2024
1 parent 34edb40 commit dc90407
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 8
version: 9

- name: Install Node.js
uses: actions/setup-node@v4
Expand Down
9 changes: 6 additions & 3 deletions src/lib/server/lizzy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,19 @@ export interface GithubDataItem {

async function fetchLizzy(path: string, init?: RequestInit) {
const url = new URL(path, LIZZY_API_URL);
const result = await fetch(url, {
const response = await fetch(url, {
...init,
headers: {
Authorization: `Bearer ${LIZZY_API_TOKEN}`,
...init?.headers,
},
});

if (!result.ok) throw result;
return result;
if (!response.ok) {
const body = await response.text();
throw new Error("Failed to fetch Lizzy: " + body, { cause: response });
}
return response;
}

let memberCache: Promise<DiscordMember[]> | null = null;
Expand Down

0 comments on commit dc90407

Please sign in to comment.