From 9c0f882ba0c7f8635ff7ab8007d134f7aefd69f2 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 30 Jun 2018 12:42:12 -0700 Subject: Add specific 404 and 401 error messages --- reader/subscription/finder.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'reader/subscription') diff --git a/reader/subscription/finder.go b/reader/subscription/finder.go index 6b45cfb..57fbd11 100644 --- a/reader/subscription/finder.go +++ b/reader/subscription/finder.go @@ -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) -- cgit v1.2.3