Skip to content

Commit

Permalink
Try…catch when parsing JSON.
Browse files Browse the repository at this point in the history
Readme corrections.
  • Loading branch information
Pierre-Elie Fauche committed Sep 26, 2012
1 parent 1194a67 commit 14908db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ klout.getUserInfluence(klout_id_or_user_id_hash, function(error, klout_response)
# Cache support

Klout suggests to store indefinitely Klout IDs obtained after requesting Klout identities.
With such cache or storage all calls basically cost 2 API calls because one is used to convert a Twitter/Facebook/Google+ user to a Klout user.
Without such cache or storage all calls basically cost 2 API calls because one is used to convert a Twitter/Facebook/Google+ user to a Klout user.

Optional parameters can be passed to `coffee_klout` so it internally stores Klout identities.
Optional parameters can be passed to coffee_klout so it internally stores Klout identities.
It can also optionally cache other API reponses.

coffee_klout currently supports only Redis clients:
Expand Down
5 changes: 4 additions & 1 deletion src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ class Klout
return callback "No cache set" unless @cache
@cache.get key, (error, result)->
return callback error or 'No cached value' if error or not result
callback null, JSON.parse(result)
try
callback null, JSON.parse(result)
catch ex
callback ex

# Set an object in cache, if a cache is configured
_setInCache: (key, value, ttl, callback)->
Expand Down

0 comments on commit 14908db

Please sign in to comment.