mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
refactor: drop the URL-based error classifier and hint lookups
Errors are named by the service call that failed: Classify, NotFoundError and ConflictError at the call site. Remove the endpoint parser that guessed the resource from the request path, and the follow-up reads the explainer made at error time (repository state, issue-vs-pull-request, the existing pull request's URL) together with the credentialed transport each API error carried for them. Calls that the endpoint parser covered and the services did not now classify themselves: issues, pull requests, reviews, comments, releases, branches, wiki pages, repositories, organizations and SSH keys. Unclassified failures fall back to the generic "not found (HTTP 404 GET ...)" text. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
20 files changed
+129
-495
No files matched your search
@@ -80,9 +80,10 @@ func (s Releases) ListPage(ctx context.Context, limit, page int) (Page[Release],
|
||||
|
||||
// View retrieves a release by its tag, including numeric tags.
|
||||
func (s Releases) View(ctx context.Context, tag string) (Release, error) {
|
||||
return repoConvert(ctx, s.Client, s.Repository, releaseFrom, func(ctx context.Context, c *gitea.Client, owner, repo string) (*gitea.Release, *gitea.Response, error) {
|
||||
item, err := repoConvert(ctx, s.Client, s.Repository, releaseFrom, func(ctx context.Context, c *gitea.Client, owner, repo string) (*gitea.Release, *gitea.Response, error) {
|
||||
return c.Releases.GetReleaseByTag(ctx, owner, repo, tag)
|
||||
})
|
||||
return item, Classify(err, "release", tag, s.Repository)
|
||||
}
|
||||
|
||||
// Latest retrieves the most recent release that is neither a draft nor a prerelease.
|
||||
@@ -102,12 +103,13 @@ func (s Releases) Archive(ctx context.Context, ref, format string) (io.ReadClose
|
||||
|
||||
// Create creates a release and lets Gitea create a missing tag at the supplied target.
|
||||
func (s Releases) Create(ctx context.Context, opts ReleaseOptions) (Release, error) {
|
||||
return repoConvert(ctx, s.Client, s.Repository, releaseFrom, func(ctx context.Context, c *gitea.Client, owner, repo string) (*gitea.Release, *gitea.Response, error) {
|
||||
item, err := repoConvert(ctx, s.Client, s.Repository, releaseFrom, func(ctx context.Context, c *gitea.Client, owner, repo string) (*gitea.Release, *gitea.Response, error) {
|
||||
return c.Releases.CreateRelease(ctx, owner, repo, gitea.CreateReleaseOption{
|
||||
TagName: deref(opts.Tag), Target: deref(opts.Target), Title: deref(opts.Title), Note: deref(opts.Body),
|
||||
IsDraft: deref(opts.Draft), IsPrerelease: deref(opts.Prerelease),
|
||||
})
|
||||
})
|
||||
return item, Classify(err, "release", deref(opts.Tag), s.Repository)
|
||||
}
|
||||
|
||||
// Edit changes only supplied release fields; Gitea ignores empty text fields.
|
||||
|
||||
Reference in new issue
Block a user