summaryrefslogtreecommitdiff
path: root/cgithub/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cgithub/src/index.ts')
-rw-r--r--cgithub/src/index.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/cgithub/src/index.ts b/cgithub/src/index.ts
index 59c98ee..eb3a0ee 100644
--- a/cgithub/src/index.ts
+++ b/cgithub/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 }));