Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitea support #8131

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve error handling
  • Loading branch information
anbraten committed Jun 4, 2022
commit dc3fdc806de6d94a78904335fafd58cd8745793c
18 changes: 6 additions & 12 deletions components/server/src/gitea/api.ts
Original file line number Diff line number Diff line change
@@ -89,20 +89,14 @@ export class GiteaRestApi {
const response = (await operation(userApi)) as R;
return response as R;
} catch (error) {
if (error && typeof error?.response?.status === "number" && error?.response?.status !== 200) {
return new Gitea.ApiError(`Gitea responded with code ${error.response.status}`, error);
if (error && error?.type === "system") {
return new Gitea.ApiError(`Gitea Fetch Error: ${error?.message}`, error);
}
if (error && error?.name === "HTTPError") {
// e.g.
// {
// "name": "HTTPError",
// "timings": { },
// "description": "404 Commit Not Found"
// }

return new Gitea.ApiError(`Gitea Request Error: ${error?.description}`, error);
if (error?.error && !error?.data && error?.error?.errors) {
return new Gitea.ApiError(`Gitea Api Error: ${error?.error?.message}`, error?.error);
}
log.error(`Gitea request error`, error);

// log.error(`Gitea request error`, error);
throw error;
} finally {
log.info(`Gitea request took ${new Date().getTime() - before} ms`);