Exception: StubRequests::EndpointNotFound
- Defined in:
- lib/stub_requests/exceptions.rb
Overview
EndpointNotFound is raised when an endpoint cannot be found
Instance Attribute Summary collapse
- #id ⇒ Object readonly
Instance Method Summary collapse
- #base_message ⇒ Object
-
#initialize(id:, suggestions: []) ⇒ EndpointNotFound
constructor
A new instance of EndpointNotFound.
- #suggestions ⇒ Object
- #suggestions_message ⇒ Object
- #suggestions_string ⇒ Object
Constructor Details
#initialize(id:, suggestions: []) ⇒ EndpointNotFound
Returns a new instance of EndpointNotFound
21 22 23 24 25 26 |
# File 'lib/stub_requests/exceptions.rb', line 21 def initialize(id:, suggestions: []) @id = id @suggestions = Array(suggestions).compact = [, ].join(".") super() end |
Instance Attribute Details
Instance Method Details
#base_message ⇒ Object
28 29 30 |
# File 'lib/stub_requests/exceptions.rb', line 28 def @base_message ||= "Couldn't find an endpoint with id=:#{id}" end |
#suggestions ⇒ Object
38 39 40 |
# File 'lib/stub_requests/exceptions.rb', line 38 def suggestions @suggestions.map { |sym| ":#{sym}" } end |
#suggestions_message ⇒ Object
32 33 34 35 36 |
# File 'lib/stub_requests/exceptions.rb', line 32 def return if suggestions.none? @suggestions_message ||= " Did you mean one of the following? (#{suggestions_string})" end |
#suggestions_string ⇒ Object
42 43 44 |
# File 'lib/stub_requests/exceptions.rb', line 42 def suggestions_string suggestions.join(", ") end |