Module: Mistri::ErrorData
- Defined in:
- lib/mistri/errors.rb
Overview
The machine-readable shape of a stream failure, carried on errored assistant messages so retry policies and hosts can classify without parsing prose. Strings are the assemblers' synthesized truncation reasons.
Class Method Summary collapse
Class Method Details
.for(reason) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/mistri/errors.rb', line 155 def for(reason) case reason when RateLimitError { "type" => "RateLimitError", "status" => reason.status, "retry_after" => reason.retry_after }.compact when ResponseTooLargeError { "type" => "ResponseTooLargeError", "kind" => reason.kind.to_s, "limit" => reason.limit } when ResponseTooComplexError { "type" => "ResponseTooComplexError", "kind" => reason.kind.to_s, "limit" => reason.limit } when ProviderError { "type" => reason.class.name.split("::").last, "status" => reason.status }.compact when Exception then { "type" => reason.class.name } else { "type" => "TruncatedStream" } end end |