Exception: Fizzy::AmbiguousError

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

Overview

Raised when a name/identifier matches multiple resources.

Instance Attribute Summary collapse

Attributes inherited from Error

#cause, #code, #hint, #http_status, #request_id, #retry_after, #retryable

Instance Method Summary collapse

Methods inherited from Error

#exit_code, exit_code_for, #retryable?

Constructor Details

#initialize(resource, matches: []) ⇒ AmbiguousError

Returns a new instance of AmbiguousError.



219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/fizzy/errors.rb', line 219

def initialize(resource, matches: [])
  @matches = matches
  hint = if matches.any? && matches.length <= 5
           "Did you mean: #{matches.join(", ")}"
  else
           "Be more specific"
  end
  super(
    code: ErrorCode::AMBIGUOUS,
    message: "Ambiguous #{resource}",
    hint: hint
  )
end

Instance Attribute Details

#matchesArray<String> (readonly)

Returns list of matching resources.

Returns:

  • (Array<String>)

    list of matching resources



217
218
219
# File 'lib/fizzy/errors.rb', line 217

def matches
  @matches
end