Sha256: 19a379a0e427a12500a5deccf24ca3b56878950da5c405512cb9113dec57336b

Contents?: true

Size: 486 Bytes

Versions: 4

Compression:

Stored size: 486 Bytes

Contents

module RDStation
  class ErrorHandler
    class Unauthorized
      attr_reader :errors

      ERROR_CODE = 'UNAUTHORIZED'.freeze

      def initialize(errors)
        @errors = errors
      end

      def raise_error
        return if unauthorized_errors.empty?
        raise RDStation::Error::Unauthorized, unauthorized_errors.first
      end

      private

      def unauthorized_errors
        errors.select { |error| error['error_type'] == ERROR_CODE }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rdstation-ruby-client-1.2.1 lib/rdstation/error_handler/unauthorized.rb
rdstation-ruby-client-1.2.0 lib/rdstation/error_handler/unauthorized.rb
rdstation-ruby-client-1.1.0 lib/rdstation/error_handler/unauthorized.rb
rdstation-ruby-client-1.0.1 lib/rdstation/error_handler/unauthorized.rb