Sha256: 183421527a93bc1b8e169e0c372fba526a37e2f073e97e091389394b5049049b

Contents?: true

Size: 1.39 KB

Versions: 12

Compression:

Stored size: 1.39 KB

Contents

module Masheri
  class NoClassGiven < Exception
    def initialize
      super("Cannot create new instance for query builder because class was not given!")
    end
  end

  class InvalidDateRange < Exception
    def initialize(start_date, end_date)
      days = ((end_date - start_date) / 1.day).ceil

      super("Your start_date and end_date are #{days} days apart. Mashery's API does not like date ranges that span longer than 7 days. Please use multiple queries to gather your data.")
    end
  end

  class QueryParamMissing < Exception
    def initialize(param)
      super "Couldn't complete request. The query param #{param.inspect} is missing."
    end
  end

  class ParamMissing < Exception
    def initialize(param)
      super "Couldn't determine Mashery #{param.inspect}! Please check your config/masheri.yml"
    end
  end

  class ConfigMissing < Exception
    def initialize
      super "No configuration has been loaded! Please call Masheri.load_config! with a valid Yaml file."
    end
  end

  class MissingConfig < Exception
    def initialize
      super("Couldn't find config/masheri.yml! \n" +
        "Please run `rails g masheri:install` to create one and populate it with the necessary API credentials.")
    end
  end

  class UnknownFormat < Exception
    def initialize(format)
      super "Unknown format #{format.inspect} for REST API call. Standard formats are CSV and JSON."
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
masheri-0.6.1 lib/masheri/exceptions.rb
masheri-0.6.0 lib/masheri/exceptions.rb
masheri-0.5.6 lib/masheri/exceptions.rb
masheri-0.5.5 lib/masheri/exceptions.rb
masheri-0.5.2 lib/masheri/exceptions.rb
masheri-0.5.1 lib/masheri/exceptions.rb
masheri-0.5.0 lib/masheri/exceptions.rb
masheri-0.4.0 lib/masheri/exceptions.rb
masheri-0.3.10 lib/masheri/exceptions.rb
masheri-0.3.8 lib/masheri/exceptions.rb
masheri-0.3.7 lib/masheri/exceptions.rb
masheri-0.3.6 lib/masheri/exceptions.rb