Skip to main content

holographic_memory/core/
error.rs

1// Copyright 2024-2026 WritersLogic Contributors
2// SPDX-License-Identifier: Apache-2.0
3
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6use thiserror::Error;
7use ts_rs::TS;
8
9#[derive(Debug, Error, Clone, Serialize, Deserialize, TS, JsonSchema)]
10#[ts(export, export_to = "bindings/")]
11#[serde(tag = "type", content = "message")]
12pub enum HmsError {
13    #[error("Invalid parameter: {details}")]
14    InvalidParam { details: String },
15
16    #[error("Storage failure: {context}")]
17    StorageFailure { context: String },
18
19    #[error("Encoding failed: {context}")]
20    EncodingFailure { context: String },
21
22    #[error("Query failed: {context}")]
23    QueryFailure { context: String },
24
25    #[error("Index not trained: {index_type}")]
26    IndexNotTrained { index_type: String },
27
28    #[error("Capacity exceeded: {limit}")]
29    CapacityExceeded { limit: String },
30
31    #[error("Internal error (code {code}): {context}")]
32    Internal { code: i32, context: String },
33}