classifyModelCallError inspects an error returned by an embedding or LLM call made during indexing. Permanent failures are wrapped with errIndexingAborted so callers can abort the run; transient failures (5xx, timeouts) and context cancellation are returned unchanged so callers can skip the current
(err error)
| 21 | // timeouts) and context cancellation are returned unchanged so callers can |
| 22 | // skip the current file and continue. |
| 23 | func classifyModelCallError(err error) error { |
| 24 | if err == nil { |
| 25 | return nil |
| 26 | } |
| 27 | if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) { |
| 28 | return err |
| 29 | } |
| 30 | // Rate-limited (429) errors are also non-retryable here: continuing to |
| 31 | // index would keep hammering a provider that asked us to back off. |
| 32 | retryable, _, _ := modelerrors.ClassifyModelError(err) |
| 33 | if !retryable { |
| 34 | return fmt.Errorf("%w: %w", errIndexingAborted, err) |
| 35 | } |
| 36 | return err |
| 37 | } |
| 38 | |
| 39 | // isIndexingAborted reports whether err carries the errIndexingAborted marker. |
| 40 | func isIndexingAborted(err error) bool { |