Skip to content

Commit

Permalink
Refactor HTTP Client and LocalizedError packages
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed Oct 22, 2023
1 parent 120aabf commit 168454e
Show file tree
Hide file tree
Showing 104 changed files with 1,256 additions and 10,657 deletions.
2 changes: 0 additions & 2 deletions .github/codeql/config.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ jobs:

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/config.yml

- name: Autobuild
uses: github/codeql-action/autobuild@v2
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/coreos/go-oidc/v3 v3.7.0
github.com/gorilla/mux v1.8.0
github.com/lib/pq v1.10.9
github.com/mccutchen/go-httpbin/v2 v2.11.1
github.com/prometheus/client_golang v1.17.0
github.com/tdewolff/minify/v2 v2.19.10
github.com/yuin/goldmark v1.5.6
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/mccutchen/go-httpbin/v2 v2.11.1 h1:itBs6fEQvMKcGKIbMI9xzoGPZV56o2EMHA2rkCIdmLw=
github.com/mccutchen/go-httpbin/v2 v2.11.1/go.mod h1:f4DUXYlU6yH0V81O4lJIwqpmYdTXXmYwzxMnYEimFPk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q=
Expand Down
12 changes: 6 additions & 6 deletions internal/api/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func (h *handler) createFeed(w http.ResponseWriter, r *http.Request) {
return
}

feed, err := feedHandler.CreateFeed(h.store, userID, &feedCreationRequest)
if err != nil {
json.ServerError(w, r, err)
feed, localizedError := feedHandler.CreateFeed(h.store, userID, &feedCreationRequest)
if localizedError != nil {
json.ServerError(w, r, localizedError.Error())
return
}

Expand All @@ -59,9 +59,9 @@ func (h *handler) refreshFeed(w http.ResponseWriter, r *http.Request) {
return
}

err := feedHandler.RefreshFeed(h.store, userID, feedID, false)
if err != nil {
json.ServerError(w, r, err)
localizedError := feedHandler.RefreshFeed(h.store, userID, feedID, false)
if localizedError != nil {
json.ServerError(w, r, localizedError.Error())
return
}

Expand Down
9 changes: 5 additions & 4 deletions internal/api/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (h *handler) discoverSubscriptions(w http.ResponseWriter, r *http.Request)
rssbridgeURL = intg.RSSBridgeURL
}

subscriptions, finderErr := subscription.FindSubscriptions(
subscriptions, localizedError := subscription.FindSubscriptions(
subscriptionDiscoveryRequest.URL,
subscriptionDiscoveryRequest.UserAgent,
subscriptionDiscoveryRequest.Cookie,
Expand All @@ -42,12 +42,13 @@ func (h *handler) discoverSubscriptions(w http.ResponseWriter, r *http.Request)
subscriptionDiscoveryRequest.AllowSelfSignedCertificates,
rssbridgeURL,
)
if finderErr != nil {
json.ServerError(w, r, finderErr)

if localizedError != nil {
json.ServerError(w, r, localizedError.Error())
return
}

if subscriptions == nil {
if len(subscriptions) == 0 {
json.NotFound(w, r)
return
}
Expand Down
31 changes: 0 additions & 31 deletions internal/errors/errors.go

This file was deleted.

10 changes: 5 additions & 5 deletions internal/googlereader/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,9 @@ func (h *handler) quickAddHandler(w http.ResponseWriter, r *http.Request) {
return
}

subscriptions, s_err := mfs.FindSubscriptions(url, "", "", "", "", false, false, "")
if s_err != nil {
json.ServerError(w, r, s_err)
subscriptions, localizedError := mfs.FindSubscriptions(url, "", "", "", "", false, false, "")
if localizedError != nil {
json.ServerError(w, r, localizedError.Error())
return
}

Expand Down Expand Up @@ -746,9 +746,9 @@ func subscribe(newFeed Stream, category Stream, title string, store *storage.Sto
return nil, verr.Error()
}

created, err := mff.CreateFeed(store, userID, &feedRequest)
created, localizedError := mff.CreateFeed(store, userID, &feedRequest)
if err != nil {
return nil, err
return nil, localizedError.Error()
}

if title != "" {
Expand Down
Loading

0 comments on commit 168454e

Please sign in to comment.