summaryrefslogtreecommitdiff
path: root/cgithub/src/scraper.ts
diff options
context:
space:
mode:
authorJoe Mou <dev@mou.fo>2026-01-27 11:23:11 -0500
committerJoe Mou <dev@mou.fo>2026-01-27 12:51:04 -0500
commit04bbba0a7b71f1fb090d3e3a73110a00c36bf765 (patch)
treefdc8e8ed5584cadb3f83735cd8f5e8b48c8304d9 /cgithub/src/scraper.ts
parentad2871ca617899aa36a2d85b41974bae9796ace6 (diff)
Propagate GitHub HTTP errors
Render `error.eta` on HTTP error from GitHub. Implemented with Gemini.
Diffstat (limited to 'cgithub/src/scraper.ts')
-rw-r--r--cgithub/src/scraper.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/cgithub/src/scraper.ts b/cgithub/src/scraper.ts
index 4feda73..b76f8c8 100644
--- a/cgithub/src/scraper.ts
+++ b/cgithub/src/scraper.ts
@@ -1,3 +1,13 @@
+export class GitHubHTTPError extends Error {
+ status: number;
+
+ constructor(status: number, message: string) {
+ super(message);
+ this.name = "GitHubHTTPError";
+ this.status = status;
+ }
+}
+
interface TreeItem {
contentType: "directory" | "file";
name: string;
@@ -78,6 +88,7 @@ async function fetchGitHubPage(path: string): Promise<string> {
"Accept-Language": "en-US,en;q=0.5",
};
const response = await fetch(`https://github.com/${path}`, { headers });
+ if (!response.ok) throw new GitHubHTTPError(response.status, response.statusText);
return response.text();
}