Errors
Stable failures for configuration, storage, providers, verification, promotion and cleanup.
import { SwapAIError } from "@swapai/core";
try {
await relevance.requestTraining();
} catch (error) {
if (error instanceof SwapAIError) {
logger.error({ code: error.code, cause: error.cause }, error.message);
}
}Failure classes
| Failure | Meaning |
|---|---|
| Invalid configuration or result | The declared task or a value violates its contract. |
| Not trained | Classification was requested without an available reference or promoted model. |
| Storage or migration | SQLite, a transaction or a supported schema migration failed. |
| Dataset not ready | Training was not started; the returned deficits explain what is missing. |
| Provider or reconciliation | Infrastructure failed, timed out or cannot yet be reconciled. |
| Runner verification | A manifest, input hash, output hash or runner format did not match. |
| Candidate rejected | Protected evaluation did not meet the release policy. |
| Promotion refused | The named run is not a valid candidate for the current generation. |
| Cleanup or erasure | External resources or managed data could not be proved absent. |
Background failures
Collection uses a queue so request latency does not include every SQLite write. Report queued failures through onBackgroundError, and call flush() where durability must be acknowledged.
Training, reconciliation, promotion and erasure are operator actions. They reject directly and must be observed by the command, job or API that invoked them.
Never treat an unknown cleanup state as success. Keep the run visible and call reconcileTraining() again after the provider is reachable.