Exception: Basecamp::AmbiguousError

Inherits:
Error
  • Object
show all
Defined in:
lib/basecamp/ambiguous_error.rb

Overview

Raised when a name/identifier matches multiple resources.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of AmbiguousError.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/basecamp/ambiguous_error.rb', line 9

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



7
8
9
# File 'lib/basecamp/ambiguous_error.rb', line 7

def matches
  @matches
end