mirror of
https://github.com/miniflux/v2.git
synced 2025-09-05 18:41:01 +00:00
Add specific 404 and 401 error messages
This commit is contained in:
parent
a40f592aab
commit
9c0f882ba0
9 changed files with 54 additions and 19 deletions
|
@ -24,6 +24,8 @@ var (
|
|||
errConnectionFailure = "Unable to open this link: %v"
|
||||
errUnreadableDoc = "Unable to analyze this page: %v"
|
||||
errEmptyBody = "This web page is empty"
|
||||
errNotAuthorized = "You are not authorized to access this resource (invalid username/password)"
|
||||
errServerFailure = "Unable to fetch this resource (Status Code = %d)"
|
||||
)
|
||||
|
||||
// FindSubscriptions downloads and try to find one or more subscriptions from an URL.
|
||||
|
@ -40,6 +42,14 @@ func FindSubscriptions(websiteURL, username, password string) (Subscriptions, er
|
|||
return nil, errors.NewLocalizedError(errConnectionFailure, err)
|
||||
}
|
||||
|
||||
if response.IsNotAuthorized() {
|
||||
return nil, errors.NewLocalizedError(errNotAuthorized)
|
||||
}
|
||||
|
||||
if response.HasServerFailure() {
|
||||
return nil, errors.NewLocalizedError(errServerFailure, response.StatusCode)
|
||||
}
|
||||
|
||||
// Content-Length = -1 when no Content-Length header is sent
|
||||
if response.ContentLength == 0 {
|
||||
return nil, errors.NewLocalizedError(errEmptyBody)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue