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:
bircni committed 2026-10-12 10:40:45 +02:00
1 parent ea13c9e4f5
commit 27e39ec4be
20 files changed
+129 -495

No files matched your search

+5 -3
View File
@@ -9,6 +9,7 @@ import (
"fmt"
"net/http"
"net/url"
"strconv"
"sync"
gitea "gitea.dev/sdk"
@@ -94,7 +95,7 @@ func (s Organizations) View(ctx context.Context, name string) (Organization, err
return c.Organizations.GetOrg(ctx, name)
})
if err != nil {
return Organization{}, err
return Organization{}, Classify(err, "organization", strconv.Quote(name), "")
}
return organizationFrom(org), nil
}
@@ -159,7 +160,7 @@ func (s Organizations) Create(ctx context.Context, opts OrganizationOptions) (Or
})
})
if err != nil {
return Organization{}, err
return Organization{}, Classify(err, "organization", "", "")
}
return organizationFrom(org), nil
}
@@ -176,9 +177,10 @@ func (s Organizations) Edit(ctx context.Context, name string, opts OrganizationO
// Delete deletes the named organization.
func (s Organizations) Delete(ctx context.Context, name string) error {
return do(ctx, s.Client, func(ctx context.Context, c *gitea.Client) (*gitea.Response, error) {
err := do(ctx, s.Client, func(ctx context.Context, c *gitea.Client) (*gitea.Response, error) {
return c.Organizations.DeleteOrg(ctx, name)
})
return Classify(err, "organization", strconv.Quote(name), "")
}
// OrganizationMember identifies a member without exposing private profile fields.