Exception: JenkinsApi::Exceptions::ForbiddenWithCrumb

Inherits:
Forbidden show all
Defined in:
lib/jenkins_api_client/exceptions.rb

Overview

Note:

the ‘refresh_crumbs’ method will update crumb enablement and the stored crumb if called with ‘true’

This exception should be thrown specifically when the caller has had a ForbiddenException and has been able to determine that a (valid) crumb was used, and the attempt still failed. This may require an interim attempt to re-acquire the crumb in order to confirm it has not expired.

Examples:

A condition where this exception would be raised

def operation
  retried = false
  begin
    make_attempt
  rescue Forbidden => e
    refresh_crumbs(true)
    if @crumbs_enabled
      if !retried
        retried = true
        retry
      else
        raise ForbiddenWithCrumb.new(@logger, e.message)
      end
    else
      raise
    end
  end
end

Instance Method Summary (collapse)

Constructor Details

- (ForbiddenWithCrumb) initialize(logger, message = '', log_level = Logger::ERROR)

Returns a new instance of ForbiddenWithCrumb



137
138
139
140
# File 'lib/jenkins_api_client/exceptions.rb', line 137

def initialize(logger, message = '', log_level = Logger::ERROR)
  msg = "A crumb was used in attempt to access operation. #{message}"
  super(logger, msg)
end