lib/hallon/error.rb in hallon-0.12.0 vs lib/hallon/error.rb in hallon-0.13.0

- old
+ new

@@ -44,13 +44,20 @@ Spotify.error_message disambiguate(error)[0] end # Raise an {Error} with the given errno, unless it is `nil`, `:timeout`, `0` or `:ok`. # + # @example + # + # Hallon::Error.maybe_raise(error, ignore: :is_loading) + # # @param [Fixnum, Symbol] error + # @param [Hash] options + # @option options [Array] :ignore ([]) other values to ignore of error # @return [nil] - def maybe_raise(x) - return nil if [nil, :timeout, :is_loading].include?(x) + def maybe_raise(x, options = {}) + ignore = [nil, :timeout] + Array(options[:ignore]) + return nil if ignore.include?(x) error, symbol = disambiguate(x) return symbol if symbol == :ok message = []