diff options
Diffstat (limited to 'src/index.ts')
| -rw-r--r-- | src/index.ts | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/index.ts b/src/index.ts index 59c98ee..eb3a0ee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,7 @@ import { getGitHubRepo, getGitHubTree, GitHubHTTPError, + RedirectError, } from "./scraper.ts"; const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); @@ -32,7 +33,9 @@ async function tryRender<T extends object>(c: Context, template: string, promise try { data = await promise; } catch (e) { - if (e instanceof GitHubHTTPError) { + if (e instanceof RedirectError) { + return c.redirect(e.location); + } else if (e instanceof GitHubHTTPError) { c.status(e.status as StatusCode); const message = `GitHub responded with HTTP ${e.status} ${e.message}`; return c.html(await eta.renderAsync("error.eta", { title: e.message, message })); |
