Sha256: d8ac13f3a08d76dac47a50b4838e932c87f222c9bd06588b183b1baac47fce50

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

module BusinessCentral

  class BusinessCentralError < StandardError; end

  class InvalidClientException < BusinessCentralError
    def message
      'Invalid client setup'
    end
  end

  class ApiException < BusinessCentralError
    def initialize(message)
      @message = message
    end

    def message
      @message
    end
  end

  class CompanyNotFoundException < BusinessCentralError
    def message
      'Company not found'
    end
  end

  class UnauthorizedException < BusinessCentralError
    def message
      'Unauthorized - The credentials provided are incorrect'
    end
  end

  class InvalidObjectException < BusinessCentralError
    def initialize(errors)
      @errors = errors
    end

    def message
      @errors.each do |error|
        "#{error[:field]} - #{error[:message]}"
      end
    end
  end

  class NoSupportedMethod < BusinessCentralError
    def initialize(method, allowed_methods)
      @method = method
      @allowed_methods = allowed_methods
    end

    def message
      "#{method} method is currently not support. Allowed methods are: #{allowed_methods.join(', ')}"
    end
  end

  class InvalidArgumentException < BusinessCentralError
    def initialize(message)
      @message = message
    end

    def message
      "Invalid argument entered - #{@message}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
business-central-1.0.3 lib/business_central/exceptions.rb