Sha256: 73ebc50e33a09e21c3c3e9c60e9ccf921e74cfab98c6013e8ba4c2f83f8b7bd8
Contents?: true
Size: 1.26 KB
Versions: 4
Compression:
Stored size: 1.26 KB
Contents
# coding: utf-8 module Hallon # Thrown by Hallon on libspotify errors. # # Hallon::Error inherits two methods from Spotify::Error: # # - Hallon::Error.explain(error) - from a Spotify error, create a descriptive string of it # - Hallon::Error.disambiguate(error) - return the tuple of [code, symbol] of a given Spotify error # # @see http://developer.spotify.com/en/libspotify/docs/group__error.html class Error < Spotify::Error class << self # Hash of error (Symbol) to code (Integer). # # @return [Hash<Symbol, Integer>] def table Spotify.enum_type(:error).to_hash 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(error, options = {}) ignore = [nil, :timeout] + Array(options[:ignore]) return nil if ignore.include?(error) error, symbol = disambiguate(error) return symbol if symbol == :ok raise self, explain(error) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hallon-0.18.2 | lib/hallon/error.rb |
hallon-0.18.1 | lib/hallon/error.rb |
hallon-0.18.0 | lib/hallon/error.rb |
hallon-0.17.0 | lib/hallon/error.rb |