Exception: Ollama::HTTPError

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

Overview

HTTP error with retry logic

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status_code = nil) ⇒ HTTPError

Returns a new instance of HTTPError.



61
62
63
64
# File 'lib/ollama/errors.rb', line 61

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.



59
60
61
# File 'lib/ollama/errors.rb', line 59

def status_code
  @status_code
end

Instance Method Details

#retryable?Boolean

Returns:

  • (Boolean)


66
67
68
69
70
71
72
73
74
75
76
# File 'lib/ollama/errors.rb', line 66

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