Skip to content

Commit

Permalink
Merge pull request #26 from singer-io/raise_auth_exception_on_401
Browse files Browse the repository at this point in the history
Raise AuthException on 401 response
  • Loading branch information
nick-mccoy authored Aug 2, 2018
2 parents fae2f86 + 3bce98b commit 23be408
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tap_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@
'reviews': ['id']
}

class AuthException(Exception):
pass

def authed_get(source, url, headers={}):
with metrics.http_request_timer(source) as timer:
session.headers.update(headers)
resp = session.request(method='get', url=url)
if resp.status_code == 401:
raise AuthException(resp.text)

timer.tags[metrics.Tag.http_status_code] = resp.status_code
return resp

Expand Down

0 comments on commit 23be408

Please sign in to comment.