opti/panda_doc

View on GitHub
lib/panda_doc/failure_result.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

module PandaDoc
  class FailureResult < StandardError
    extend Forwardable
    def_delegators :response, :status, :success?
    def_delegators :error, :type, :detail

    attr_reader :error

    attr_reader :response

    def initialize(response)
      @response = response
      @error = Objects::Error.new(response.body)
    end

    def to_s
      "#{status} #{type}: #{detail}"
    end
  end
end