Skip to content

Commit

Permalink
Handle LoadError properly
Browse files Browse the repository at this point in the history
Sometimes LoadError is raised while loading oj gem, even if oj gem is
installed. Therefore we want to see the correct message of LoadError.

For example, Alpine Linux provides the package ruby which does not
include bigdecimal and provides ruby-bigdecimal.

Signed-off-by: Kenji Okimoto <[email protected]>
  • Loading branch information
okkez committed Sep 25, 2018
1 parent 19b6cd6 commit 05b17c0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/fluent/plugin/parser_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,15 @@ def configure_json_parser(name)
else
raise "BUG: unknown json parser specified: #{name}"
end
rescue LoadError
rescue LoadError => ex
name = :yajl
log.info "Oj is not installed, and failing back to Yajl for json parser" if log
if log
if /\boj\z/ =~ ex.message
log.info "Oj is not installed, and failing back to Yajl for json parser"
else
log.warn ex.message
end
end
retry
end

Expand Down

0 comments on commit 05b17c0

Please sign in to comment.