kora_core/error.rs
1//! Core error types for the Kōra engine.
2//!
3//! `KoraError` covers the error conditions that arise during command execution:
4//! type mismatches, arity violations, non-integer values, and shutdown. All
5//! variants produce RESP-compatible error messages so the protocol layer can
6//! relay them directly to clients.
7
8use thiserror::Error;
9
10/// Errors that can occur during cache operations.
11#[derive(Debug, Error)]
12pub enum KoraError {
13 /// The operation was performed on a key with an incompatible value type.
14 #[error("WRONGTYPE Operation against a key holding the wrong kind of value")]
15 WrongType,
16
17 /// The command received an invalid number of arguments.
18 #[error("ERR wrong number of arguments for '{0}' command")]
19 WrongArity(String),
20
21 /// A value could not be parsed as an integer.
22 #[error("ERR value is not an integer or out of range")]
23 NotAnInteger,
24
25 /// The engine is shutting down.
26 #[error("ERR server is shutting down")]
27 ShuttingDown,
28
29 /// A generic error with a message.
30 #[error("ERR {0}")]
31 Other(String),
32}
33
34/// Convenience result type for core operations.
35pub type Result<T> = std::result::Result<T, KoraError>;