Sha256: e1ea3c4a07d5ed817a17d415948c82aff3152b73aacff663ba287c1fb9a64eb5

Contents?: true

Size: 1.99 KB

Versions: 2

Compression:

Stored size: 1.99 KB

Contents

module Auth0
  # Default exception in namespace of Auth0
  # if you want to catch all exceptions, then you should use this one.
  # Network exceptions are not included
  class Exception < StandardError
    attr_reader :error_data
    def initialize(message,error_data={})
      super(message)
      @error_data = error_data
    end
  end
  # Parent for all exceptions that arise out of HTTP error responses.
  class HTTPError < Auth0::Exception
    def headers
      error_data[:headers]
    end

    def http_code
      error_data[:code]
    end
  end
  # exception for unauthorized requests, if you see it,
  # probably Bearer Token is not set correctly
  class Unauthorized < Auth0::HTTPError; end
  # exception for not found resource, you query for an
  # unexistent resource, or wrong path
  class NotFound < Auth0::HTTPError; end
  # exception for unknown error
  class Unsupported < Auth0::HTTPError; end
  # exception for server error
  class ServerError < Auth0::HTTPError; end
  # exception for incorrect request, you've sent wrong params
  class BadRequest < Auth0::HTTPError; end
  # exception for timeouts
  class RequestTimeout < Auth0::Exception; end
  # exception for unset user_id, this might cause removal of
  # all users, or other unexpected behaviour
  class MissingUserId < Auth0::Exception; end
  # exception for unset client_id
  class MissingClientId < Auth0::Exception; end
  # exception for an unset parameter
  class MissingParameter < Auth0::Exception; end
  # Api v2 access denied
  class AccessDenied < Auth0::HTTPError; end
  # Invalid parameter passed, e.g. empty where ID is required
  class InvalidParameter < Auth0::Exception; end
  # Invalid JWT
  class InvalidCredentials < Auth0::Exception; end
  # Invalid Auth0 API namespace
  class InvalidApiNamespace < Auth0::Exception; end
  # Auth0 API rate-limiting encountered
  class RateLimitEncountered < Auth0::HTTPError
    def reset
      Time.at(headers['X-RateLimit-Reset']).utc
    end
  end

  class InvalidIdToken < Auth0::Exception; end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
auth0-5.0.1 lib/auth0/exception.rb
auth0-5.0.0 lib/auth0/exception.rb