Skip to content

Commit

Permalink
raise better error if can’t authenticate
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorfinnell committed Oct 2, 2018
1 parent 8e0c156 commit 23fa0be
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: hqtrivia
version: 0.2.2
version: 0.2.3

authors:
- Taylor Finnell <[email protected]>
Expand Down
5 changes: 5 additions & 0 deletions src/hqtrivia/show_coordinator/hq_coordinator.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module HqTrivia
class HttpException < Exception
end

class NotAuthenticatedError < Exception
end

def current_show
connection_failed = ->(ex : Exception) do
HqTrivia.logger.debug("#{self.class.name}: Connection to HQ (#{@country}) server failed...retrying. #{ex}")
Expand All @@ -13,6 +16,8 @@ module HqTrivia

if (200..299).includes?(resp.status_code)
Model::Show.from_json(resp.body)
elsif resp.status_code == 401
raise NotAuthenticatedError.new("Could not authenticate #{@country}, the token is probably expired")
else
raise HttpException.new("#{resp.body} (#{resp.status_code}) (country: #{@country})")
end
Expand Down
2 changes: 1 addition & 1 deletion src/hqtrivia/version.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module HqTrivia
# Current HqTrivia version
VERSION = "0.2.2"
VERSION = "0.2.3"
end

0 comments on commit 23fa0be

Please sign in to comment.