fix: surface real network cause on Gitea issue creation failure (v0.51.4)
A thrown fetch error (DNS failure, connection refused, timeout) never reached the res.ok branch, so its actual cause was lost — err.message alone is often just "fetch failed" with the real reason nested in err.cause. Now logs the full cause server-side and folds it into the error returned to the admin support view's tooltip. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+10
-1
@@ -50,6 +50,15 @@ export async function createGiteaIssue(opts: {
|
||||
const issue = (await res.json()) as { html_url?: string };
|
||||
return { url: issue.html_url ?? null, error: issue.html_url ? null : "Gitea response had no html_url" };
|
||||
} catch (err) {
|
||||
return { url: null, error: err instanceof Error ? err.message : "Unknown error" };
|
||||
// A thrown fetch error (DNS failure, connection refused, timeout, TLS
|
||||
// error) never reaches the res.ok branch above, so its real cause would
|
||||
// otherwise be lost — err.message alone is often just "fetch failed"
|
||||
// with the actual reason nested in err.cause. Log server-side with the
|
||||
// full cause chain, and fold a short form into the returned message so
|
||||
// it also shows up in the admin support view's tooltip, not just logs.
|
||||
const cause = err instanceof Error && err.cause instanceof Error ? err.cause.message : undefined;
|
||||
const message = err instanceof Error ? err.message : "Unknown error";
|
||||
console.error("[gitea] createGiteaIssue failed", { baseUrl, repo, message, cause });
|
||||
return { url: null, error: cause ? `${message}: ${cause}` : message };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user