mirror of
https://github.com/openai/codex.git
synced 2026-11-03 19:53:25 +00:00
63 lines
2.0 KiB
Rust
63 lines
2.0 KiB
Rust
use codex_protocol::ThreadId;
|
|
use codex_protocol::protocol::ThreadHistoryMode;
|
|
|
|
/// Result type returned by thread-store operations.
|
|
pub type ThreadStoreResult<T> = Result<T, ThreadStoreError>;
|
|
|
|
pub(crate) fn reject_paginated_history_mode(
|
|
history_mode: ThreadHistoryMode,
|
|
) -> ThreadStoreResult<()> {
|
|
if matches!(history_mode, ThreadHistoryMode::Paginated) {
|
|
return Err(ThreadStoreError::Unsupported {
|
|
operation: "paginated_threads",
|
|
});
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
/// Error type shared by thread-store implementations.
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum ThreadStoreError {
|
|
/// The requested thread does not exist in this store.
|
|
#[error("thread {thread_id} not found")]
|
|
ThreadNotFound {
|
|
/// Thread id requested by the caller.
|
|
thread_id: ThreadId,
|
|
},
|
|
|
|
/// The caller supplied invalid request data.
|
|
#[error("invalid thread-store request: {message}")]
|
|
InvalidRequest {
|
|
/// User-facing explanation of the invalid request.
|
|
message: String,
|
|
},
|
|
|
|
/// The operation conflicted with current store state.
|
|
#[error("thread-store conflict: {message}")]
|
|
Conflict {
|
|
/// User-facing explanation of the conflict.
|
|
message: String,
|
|
},
|
|
|
|
/// The store implementation does not support this operation yet.
|
|
#[error("thread-store unsupported operation: {operation}")]
|
|
Unsupported {
|
|
/// Stable operation name for callers that need to map unsupported operations.
|
|
operation: &'static str,
|
|
},
|
|
|
|
/// The store cannot return the requested result within a required resource limit.
|
|
#[error("thread-store resource exhausted: {message}")]
|
|
ResourceExhausted {
|
|
/// User-facing explanation of the exhausted resource.
|
|
message: String,
|
|
},
|
|
|
|
/// Catch-all for implementation failures that do not fit a more specific category.
|
|
#[error("thread-store internal error: {message}")]
|
|
Internal {
|
|
/// User-facing explanation of the implementation failure.
|
|
message: String,
|
|
},
|
|
}
|