55 lines
3.8 KiB
Rust
55 lines
3.8 KiB
Rust
// file: crates/ksp-worker-raw-transaction-ingest-lib/src/error.rs
|
|
// version: 6
|
|
|
|
/// Error code used when durable Store content conflicts with one admitted canonical RAW transaction.
|
|
pub const ERROR_CODE_RAW_TRANSACTION_INGEST_CONTENT_CONFLICT: ksp_core_lib::ErrorCode =
|
|
ksp_core_lib::ErrorCode::new("worker_raw_transaction_ingest", "content_conflict");
|
|
/// Error code used when one monotone RAW transaction ingest Worker counter or snapshot sequence cannot advance without wrapping.
|
|
pub const ERROR_CODE_RAW_TRANSACTION_INGEST_COUNTER_EXHAUSTED: ksp_core_lib::ErrorCode =
|
|
ksp_core_lib::ErrorCode::new("worker_raw_transaction_ingest", "counter_exhausted");
|
|
/// Error code used when private Worker tasks cannot drain before the configured shutdown deadline.
|
|
pub const ERROR_CODE_RAW_TRANSACTION_INGEST_DRAIN_TIMEOUT: ksp_core_lib::ErrorCode =
|
|
ksp_core_lib::ErrorCode::new("worker_raw_transaction_ingest", "drain_timeout");
|
|
/// Error code used when the RAW transaction ingest Worker reaches an invalid runtime or lifecycle condition.
|
|
pub const ERROR_CODE_RAW_TRANSACTION_INGEST_RUNTIME_INVALID: ksp_core_lib::ErrorCode =
|
|
ksp_core_lib::ErrorCode::new("worker_raw_transaction_ingest", "runtime_invalid");
|
|
/// Error code used when RAW transaction ingest Worker settings violate one bounded runtime invariant.
|
|
pub const ERROR_CODE_RAW_TRANSACTION_INGEST_SETTINGS_INVALID: ksp_core_lib::ErrorCode =
|
|
ksp_core_lib::ErrorCode::new("worker_raw_transaction_ingest", "settings_invalid");
|
|
/// Error code used when one private source task terminates with a classified failure.
|
|
pub const ERROR_CODE_RAW_TRANSACTION_INGEST_SOURCE_FAILED: ksp_core_lib::ErrorCode =
|
|
ksp_core_lib::ErrorCode::new("worker_raw_transaction_ingest", "source_failed");
|
|
/// Error code used when Store persistence fails for one admitted canonical RAW transaction.
|
|
pub const ERROR_CODE_RAW_TRANSACTION_INGEST_STORE_FAILED: ksp_core_lib::ErrorCode =
|
|
ksp_core_lib::ErrorCode::new("worker_raw_transaction_ingest", "store_failed");
|
|
|
|
/// Creates one terminal counter-exhaustion error without exposing runtime material.
|
|
pub(crate) fn counter_exhausted_error(field: &'static str) -> ksp_core_lib::Error {
|
|
return ksp_core_lib::Error::new(crate::ERROR_CODE_RAW_TRANSACTION_INGEST_COUNTER_EXHAUSTED, "RAW transaction ingest Worker counter exhausted")
|
|
.with_context("field", field);
|
|
}
|
|
|
|
/// Creates one terminal content-conflict error without copying conflicting material into diagnostics.
|
|
pub(crate) fn content_conflict_error() -> ksp_core_lib::Error {
|
|
return ksp_core_lib::Error::new(crate::ERROR_CODE_RAW_TRANSACTION_INGEST_CONTENT_CONFLICT, "RAW transaction ingest Store content conflict");
|
|
}
|
|
|
|
/// Creates one runtime-domain error carrying only one stable internal condition code.
|
|
pub(crate) fn runtime_error(condition: &'static str) -> ksp_core_lib::Error {
|
|
return ksp_core_lib::Error::new(crate::ERROR_CODE_RAW_TRANSACTION_INGEST_RUNTIME_INVALID, "invalid RAW transaction ingest Worker runtime state")
|
|
.with_context("condition", condition);
|
|
}
|
|
|
|
/// Creates one settings-domain error carrying only the stable invalid field name.
|
|
pub(crate) fn settings_error(field: &'static str) -> ksp_core_lib::Error {
|
|
return ksp_core_lib::Error::new(crate::ERROR_CODE_RAW_TRANSACTION_INGEST_SETTINGS_INVALID, "invalid RAW transaction ingest Worker settings")
|
|
.with_context("field", field);
|
|
}
|
|
|
|
/// Creates one terminal Store error while retaining only the already-safe lower-layer ErrorCode.
|
|
pub(crate) fn store_error(store_code: ksp_core_lib::ErrorCode) -> ksp_core_lib::Error {
|
|
return ksp_core_lib::Error::new(crate::ERROR_CODE_RAW_TRANSACTION_INGEST_STORE_FAILED, "RAW transaction ingest Store persistence failed")
|
|
.with_context("store_domain", store_code.domain())
|
|
.with_context("store_code", store_code.code());
|
|
}
|