Skip to content

Commit

Permalink
Rename AuthenticationFailureException to AuthenticationError (use con…
Browse files Browse the repository at this point in the history
…sistent suffix and avoid semantic repetition)
  • Loading branch information
jpmckinney committed May 27, 2020
1 parent f450f60 commit 4e59a97
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion kingfisher_scrapy/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class KingfisherScrapyError(Exception):
"""Base class for exceptions from within this application"""


class AuthenticationFailureException(KingfisherScrapyError):
class AuthenticationError(KingfisherScrapyError):
"""Raised when the maximum number of attempts to retrieve an access token is reached"""


Expand Down
6 changes: 3 additions & 3 deletions kingfisher_scrapy/spiders/openopps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import scrapy

from kingfisher_scrapy.base_spider import BaseSpider
from kingfisher_scrapy.exceptions import AuthenticationFailureException
from kingfisher_scrapy.exceptions import AuthenticationError


class OpenOpps(BaseSpider):
Expand Down Expand Up @@ -93,11 +93,11 @@ def parse_access_token(self, response):
else:
self.logger.error(
'Authentication failed. Status code: {}. {}'.format(response.status, response.text))
raise AuthenticationFailureException()
raise AuthenticationError()
else:
self.logger.error(
'Authentication failed. Status code: {}. {}'.format(response.status, response.text))
raise AuthenticationFailureException()
raise AuthenticationError()

def start_requests_pages(self):
page_size = 1000
Expand Down
6 changes: 3 additions & 3 deletions kingfisher_scrapy/spiders/paraguay_dncp_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import scrapy

from kingfisher_scrapy.base_spider import BaseSpider
from kingfisher_scrapy.exceptions import AuthenticationFailureException
from kingfisher_scrapy.exceptions import AuthenticationError


class ParaguayDNCPBaseSpider(BaseSpider):
Expand Down Expand Up @@ -90,7 +90,7 @@ def parse_access_token(self, response):
if attempt == self.max_attempts:
self.logger.error('Max attempts to get an access token reached.')
self.auth_failed = True
raise AuthenticationFailureException()
raise AuthenticationError()
else:
self.logger.info('Requesting access token, attempt {} of {}'.format(
attempt + 1,
Expand All @@ -109,7 +109,7 @@ def parse_access_token(self, response):
else:
self.logger.error('Authentication failed. Status code: {}'.format(response.status))
self.auth_failed = True
raise AuthenticationFailureException()
raise AuthenticationError()

def parse_pages(self, response):
if response.status == 200:
Expand Down
6 changes: 3 additions & 3 deletions kingfisher_scrapy/spiders/paraguay_hacienda.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import scrapy

from kingfisher_scrapy.base_spider import BaseSpider
from kingfisher_scrapy.exceptions import AuthenticationFailureException
from kingfisher_scrapy.exceptions import AuthenticationError


class ParaguayHacienda(BaseSpider):
Expand Down Expand Up @@ -118,7 +118,7 @@ def parse_access_token(self, response):
if attempt == self.max_attempts:
self.logger.error('Max attempts to get an access token reached.')
self.auth_failed = True
raise AuthenticationFailureException()
raise AuthenticationError()
else:
self.logger.info('Requesting access token, attempt {} of {}'.format(
attempt + 1,
Expand All @@ -137,7 +137,7 @@ def parse_access_token(self, response):
else:
self.logger.error('Authentication failed. Status code: {}'.format(response.status))
self.auth_failed = True
raise AuthenticationFailureException()
raise AuthenticationError()

def expires_soon(self, time_diff):
""" Tells if the access token will expire soon (required by
Expand Down

0 comments on commit 4e59a97

Please sign in to comment.