Sha256: 663a95db5d3bf0bad520defcbac374244267a317b15d3af7736bcd16dcf96ac2

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 KB

Contents

module Mashery
  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/mashery.yml"
    end
  end

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

  class MissingConfig < Exception
    def initialize
      super("Couldn't find config/mashery.yml! \n" +
        "Please run `rails g mashery: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

7 entries across 7 versions & 1 rubygems

Version Path
mashery_rails-0.6.9.pre4 lib/mashery/exceptions.rb
mashery_rails-0.6.9.pre3 lib/mashery/exceptions.rb
mashery_rails-0.6.9.pre1 lib/mashery/exceptions.rb
mashery_rails-0.6.8 lib/mashery/exceptions.rb
mashery_rails-0.6.7 lib/mashery/exceptions.rb
mashery_rails-0.6.6 lib/mashery/exceptions.rb
mashery_rails-0.6.3 lib/mashery/exceptions.rb