'usage_limit_reached', 'status' => 429] : ['code' => 'knowledge_failed', 'status' => 503]; } /** Exhausted limit, not a halted kill switch, provider failure or indexing problem. */ public function isBudgetExhaustion(): bool { return $this === self::Budget; } public static function classify(\Throwable $e): self { if ($e instanceof ExtractionException && $e->failure !== null) { return $e->failure; } if ($e instanceof EmbeddingResponseException) { return $e->failure; } if ($e instanceof \Aiwend\Db\DatabaseException) { return self::Database; } if ($e instanceof \UnexpectedValueException) { return self::Index; // VectorCodec::decode rejects a stored vector of the wrong length } return self::Unknown; } }