Skip to content

Commit

Permalink
Add basic logging for exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
strzibny committed Apr 25, 2016
1 parent b5a90a7 commit a2d9666
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/hipparchus.cr
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
require "kemal"
require "json"
require "logger"
require "redis"
require "./hipparchus/google_maps_api.cr"

log = Logger.new(STDOUT)
log.level = Logger::INFO
redis = Redis.new
log.info("Connected to Redis")

get "/:address" do |env|
address = env.params.url["address"].downcase
Expand All @@ -23,6 +27,7 @@ get "/:address" do |env|
redis.set("coordinates:#{address}", location.to_json)
response = { location: location }
rescue ex : Hipparchus::GoogleMapsApi::Client::ServerError
log.info("GoogleMapsApi::Client::ServerError for address #{address}: #{ex.message}")
response = { error: ex.message }
end
end
Expand Down

0 comments on commit a2d9666

Please sign in to comment.