Exception: Ollama::NotFoundError

Inherits:
HTTPError show all
Defined in:
lib/ollama/errors.rb

Overview

Specific error for 404 Not Found responses

Instance Attribute Summary collapse

Attributes inherited from HTTPError

#status_code

Instance Method Summary collapse

Constructor Details

#initialize(message = "Resource not found", requested_model: nil, suggestions: []) ⇒ NotFoundError

Returns a new instance of NotFoundError.



41
42
43
44
45
# File 'lib/ollama/errors.rb', line 41

def initialize(message = "Resource not found", requested_model: nil, suggestions: [])
  super("HTTP 404: #{message}", 404)
  @requested_model = requested_model
  @suggestions = suggestions
end

Instance Attribute Details

#requested_modelObject (readonly)

Returns the value of attribute requested_model.



39
40
41
# File 'lib/ollama/errors.rb', line 39

def requested_model
  @requested_model
end

#suggestionsObject (readonly)

Returns the value of attribute suggestions.



39
40
41
# File 'lib/ollama/errors.rb', line 39

def suggestions
  @suggestions
end

Instance Method Details

#retryable?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/ollama/errors.rb', line 47

def retryable?
  false
end

#to_sObject



51
52
53
54
55
56
57
# File 'lib/ollama/errors.rb', line 51

def to_s
  msg = super
  return msg unless @requested_model && !@suggestions.empty?

  suggestion_text = @suggestions.map { |m| "  - #{m}" }.join("\n")
  "#{msg}\n\nModel '#{@requested_model}' not found. Did you mean one of these?\n#{suggestion_text}"
end