Exception: Safire::Errors::DiscoveryError

Inherits:
Error
  • Object
show all
Defined in:
lib/safire/errors.rb

Overview

Raised when protocol discovery fails.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint:, status: nil, error_description: nil, label: 'SMART configuration') ⇒ DiscoveryError

Returns a new instance of DiscoveryError.



96
97
98
99
100
101
102
# File 'lib/safire/errors.rb', line 96

def initialize(endpoint:, status: nil, error_description: nil, label: 'SMART configuration')
  @endpoint          = endpoint
  @status            = status
  @error_description = error_description
  @label             = label
  super(build_message)
end

Instance Attribute Details

#endpointString (readonly)

Returns the discovery endpoint URL that was requested.

Returns:

  • (String)

    the discovery endpoint URL that was requested



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/safire/errors.rb', line 93

class DiscoveryError < Error
  attr_reader :endpoint, :status, :error_description, :label

  def initialize(endpoint:, status: nil, error_description: nil, label: 'SMART configuration')
    @endpoint          = endpoint
    @status            = status
    @error_description = error_description
    @label             = label
    super(build_message)
  end

  private

  def build_message
    msg = "Failed to discover #{@label} from #{@endpoint}"
    msg += " (HTTP #{@status})" if @status
    msg += ": #{@error_description}" if @error_description
    msg
  end
end

#error_descriptionString? (readonly)

Returns description of why discovery failed (e.g. unexpected response format).

Returns:

  • (String, nil)

    description of why discovery failed (e.g. unexpected response format)



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/safire/errors.rb', line 93

class DiscoveryError < Error
  attr_reader :endpoint, :status, :error_description, :label

  def initialize(endpoint:, status: nil, error_description: nil, label: 'SMART configuration')
    @endpoint          = endpoint
    @status            = status
    @error_description = error_description
    @label             = label
    super(build_message)
  end

  private

  def build_message
    msg = "Failed to discover #{@label} from #{@endpoint}"
    msg += " (HTTP #{@status})" if @status
    msg += ": #{@error_description}" if @error_description
    msg
  end
end

#labelString (readonly)

Returns protocol label used in the error message (e.g. 'SMART configuration', 'UDAP metadata').

Returns:

  • (String)

    protocol label used in the error message (e.g. 'SMART configuration', 'UDAP metadata')



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/safire/errors.rb', line 93

class DiscoveryError < Error
  attr_reader :endpoint, :status, :error_description, :label

  def initialize(endpoint:, status: nil, error_description: nil, label: 'SMART configuration')
    @endpoint          = endpoint
    @status            = status
    @error_description = error_description
    @label             = label
    super(build_message)
  end

  private

  def build_message
    msg = "Failed to discover #{@label} from #{@endpoint}"
    msg += " (HTTP #{@status})" if @status
    msg += ": #{@error_description}" if @error_description
    msg
  end
end

#statusInteger? (readonly)

Returns HTTP status code returned by the server.

Returns:

  • (Integer, nil)

    HTTP status code returned by the server



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/safire/errors.rb', line 93

class DiscoveryError < Error
  attr_reader :endpoint, :status, :error_description, :label

  def initialize(endpoint:, status: nil, error_description: nil, label: 'SMART configuration')
    @endpoint          = endpoint
    @status            = status
    @error_description = error_description
    @label             = label
    super(build_message)
  end

  private

  def build_message
    msg = "Failed to discover #{@label} from #{@endpoint}"
    msg += " (HTTP #{@status})" if @status
    msg += ": #{@error_description}" if @error_description
    msg
  end
end