Sha256: 0b0ff0b6b33f860d6ca65f9536bb05c2e60b3f20018b8fa6b5cf9db8c3af71bf

Contents?: true

Size: 1.37 KB

Versions: 31

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true
# typed: true


module WorkOS
  # Parent class for WorkOS related errors
  class WorkOSError < StandardError
    extend T::Sig

    attr_reader :http_status
    attr_reader :request_id

    sig do
      params(
        message: T.nilable(String),
        http_status: T.nilable(Integer),
        request_id: T.nilable(String),
      ).void
    end
    def initialize(message: nil, http_status: nil, request_id: nil)
      @message = message
      @http_status = http_status
      @request_id = request_id
    end

    sig { returns(String) }
    def to_s
      status_string = @http_status.nil? ? '' : "Status #{@http_status}, "
      id_string = @request_id.nil? ? '' : " - request ID: #{@request_id}"
      "#{status_string}#{@message}#{id_string}"
    end
  end

  # APIError is a generic error that may be raised in cases where none of the
  # other named errors cover the problem. It could also be raised in the case
  # that a new error has been introduced in the API, but this version of the
  # Ruby SDK doesn't know how to handle it.
  class APIError < WorkOSError; end

  # AuthenticationError is raised when invalid credentials are used to connect
  # to WorkOS's servers.
  class AuthenticationError < WorkOSError; end

  # InvalidRequestError is raised when a request is initiated with invalid
  # parameters.
  class InvalidRequestError < WorkOSError; end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
workos-1.2.1 lib/workos/errors.rb
workos-1.2.0 lib/workos/errors.rb
workos-1.1.0 lib/workos/errors.rb
workos-1.0.0 lib/workos/errors.rb
workos-0.11.2 lib/workos/errors.rb
workos-0.11.1 lib/workos/errors.rb
workos-0.11.0 lib/workos/errors.rb
workos-0.10.3 lib/workos/errors.rb
workos-0.10.2 lib/workos/errors.rb
workos-0.10.1 lib/workos/errors.rb
workos-0.10.0 lib/workos/errors.rb
workos-0.9.2 lib/workos/errors.rb
workos-0.9.1 lib/workos/errors.rb
workos-0.9.0 lib/workos/errors.rb
workos-0.8.1 lib/workos/errors.rb
workos-0.8.0 lib/workos/errors.rb
workos-0.7.0 lib/workos/errors.rb
workos-0.6.0 lib/workos/errors.rb
workos-0.5.0 lib/workos/errors.rb
workos-0.4.2 lib/workos/errors.rb