Sha256: 9f06b02bd0b44039033f06049dcda6c717f95bfa6ed3e9ee0ba4a00983987918

Contents?: true

Size: 615 Bytes

Versions: 1

Compression:

Stored size: 615 Bytes

Contents

module RDStation
  class ErrorHandler
    class ResourceNotFound
      attr_reader :api_response, :error

      ERROR_CODE = 'RESOURCE_NOT_FOUND'.freeze
      EXCEPTION_CLASS = RDStation::Error::ResourceNotFound

      def initialize(api_response)
        @api_response = api_response
        @error = JSON.parse(api_response.body)['errors']
      end

      def raise_error
        return unless resource_not_found?
        raise EXCEPTION_CLASS.new(error['error_message'], api_response)
      end

      private

      def resource_not_found?
        error['error_type'] == ERROR_CODE
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rdstation-ruby-client-1.0.0 lib/rdstation/error_handler/resource_not_found.rb