Exception: Ollama::HTTPError

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

Overview

HTTP error with retry logic

Direct Known Subclasses

NotFoundError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status_code = nil) ⇒ HTTPError

Returns a new instance of HTTPError.



19
20
21
22
# File 'lib/ollama/errors.rb', line 19

def initialize(message, status_code = nil)
  super(message)
  @status_code = status_code
end

Instance Attribute Details

#status_codeObject (readonly)

Returns the value of attribute status_code.



17
18
19
# File 'lib/ollama/errors.rb', line 17

def status_code
  @status_code
end

Instance Method Details

#retryable?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ollama/errors.rb', line 24

def retryable?
  # Explicit retry policy:
  # - Retry: 408 (Request Timeout), 429 (Too Many Requests),
  #   500 (Internal Server Error), 502 (Bad Gateway), 503 (Service Unavailable)
  # - Never retry: 400-407, 409-428, 430-499 (client errors)
  # - Never retry: 501, 504-599 (other server errors - may indicate permanent issues)
  return true if @status_code.nil? # Unknown status - retry for safety
  return true if [408, 429, 500, 502, 503].include?(@status_code)

  false
end