Sha256: b1d4e4cc0fd8f3740f8a9ee39552d33bef6567d6b4867f8d4c6f3feb6109f039

Contents?: true

Size: 518 Bytes

Versions: 4

Compression:

Stored size: 518 Bytes

Contents

module RDStation
  class ErrorHandler
    class ResourceNotFound
      attr_reader :errors

      ERROR_CODE = 'RESOURCE_NOT_FOUND'.freeze

      def initialize(errors)
        @errors = errors
      end

      def raise_error
        return if resource_not_found_errors.empty?
        raise RDStation::Error::ResourceNotFound, resource_not_found_errors.first
      end

      private

      def resource_not_found_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/resource_not_found.rb
rdstation-ruby-client-1.2.0 lib/rdstation/error_handler/resource_not_found.rb
rdstation-ruby-client-1.1.0 lib/rdstation/error_handler/resource_not_found.rb
rdstation-ruby-client-1.0.1 lib/rdstation/error_handler/resource_not_found.rb