diff options
| author | Joe Mou <dev@mou.fo> | 2026-01-27 11:23:11 -0500 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-01-27 12:51:04 -0500 |
| commit | 70534dacebc69e05d2674a08b4b75b352b8a8913 (patch) | |
| tree | 3587cdc273adc2c65c870d18e08ae915addb34a0 /src/scraper.ts | |
| parent | 737770b900a6a063d83e384faf09dfa4f2a15ebd (diff) | |
Propagate GitHub HTTP errors
Render `error.eta` on HTTP error from GitHub.
Implemented with Gemini.
Diffstat (limited to 'src/scraper.ts')
| -rw-r--r-- | src/scraper.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/scraper.ts b/src/scraper.ts index 4feda73..b76f8c8 100644 --- a/src/scraper.ts +++ b/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(); } |
