Skip to content

Commit

Permalink
Raise exception if none of json libraries could be required.
Browse files Browse the repository at this point in the history
Instead of returning nil and let it break in another place, raise
exception as soon as thing goes wrong.
  • Loading branch information
spacewander committed Apr 17, 2018
1 parent 13b6dd6 commit 94061ab
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/sawyer/serializer.rb
Expand Up @@ -4,7 +4,13 @@
module Sawyer
class Serializer
def self.any_json
yajl || multi_json || json
serializer = yajl || multi_json || json

if not serializer
raise RuntimeError, "'json' library is need but could not be required"
end

serializer
end

def self.yajl
Expand Down

0 comments on commit 94061ab

Please sign in to comment.