Sha256: 1e3edc48049f8fced43432bd76658dd6f33363f50bcd73314ede5f893026c4b4

Contents?: true

Size: 1.92 KB

Versions: 4

Compression:

Stored size: 1.92 KB

Contents

module Xeroizer
  class ApiException < StandardError
    
    def initialize(type, message, xml)
      @type     = type
      @message  = message
      @xml      = xml
    end
    
    def message
      "#{@type}: #{@message} \n Generated by the following XML: \n #{@xml}"
    end
    
  end
  
  class UnparseableResponse < StandardError
    
    def initialize(root_element_name)
      @root_element_name = root_element_name
    end
    
    def message
      "A root element of #{@root_element_name} was returned, and we don't understand that!"
    end
      
  end
  
  class ObjectNotFound < StandardError
    
    def initialize(api_endpoint)
      @api_endpoint = api_endpoint
    end
    
    def message
      "Couldn't find object for API Endpoint #{@api_endpoint}"
    end
    
  end
  
  class InvoiceNotFoundError < StandardError; end

  class CreditNoteNotFoundError < StandardError; end
  
  class MethodNotAllowed < StandardError
    
    def initialize(klass, method)
      @klass = klass
      @method = method
    end
    
    def message
      "Method #{@method} not allowed on #{@klass}"
    end
    
  end
  
  class RecordKeyMustBeDefined < StandardError
    
    def initialize(possible_keys)
      @possible_keys = possible_keys
    end
    
    def message
      "One of the keys #{@possible_keys.join(', ')} need to be defined to update the record."
    end
    
  end

  class SettingTotalDirectlyNotSupported < StandardError
    
    def initialize(attribute_name)
      @attribute_name = attribute_name
    end
    
    def message
      "Can't set the total #{@attribute_name} directly as this is calculated automatically."
    end
    
  end

  class InvalidAttributeInWhere < StandardError
    
    def initialize(model_name, attribute_name)
      @model_name = model_name
      @attribute_name = attribute_name
    end
    
    def message
      "#{@attribute_name} is not an attribute of #{@model_name}."
    end
    
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xeroizer-0.2.0 lib/xeroizer/exceptions.rb
xeroizer-0.1.3 lib/xeroizer/exceptions.rb
xeroizer-0.1.2 lib/xeroizer/exceptions.rb
xeroizer-0.1.0 lib/xeroizer/exceptions.rb