Skip to main content

nexql_tools/
error.rs

1// SPDX-License-Identifier: GPL-3.0-only
2// Copyright (C) 2026 NexQL-OSS Team
3
4use nexql_conn::format_postgres_error;
5use thiserror::Error;
6
7#[derive(Debug, Error)]
8pub enum ToolError {
9    #[error("unknown tool: {0}")]
10    Unknown(String),
11
12    #[error("invalid arguments: {0}")]
13    InvalidArgs(String),
14
15    #[error("tool execution failed: {0}")]
16    Execution(String),
17
18    #[error(transparent)]
19    Conn(#[from] nexql_conn::ConnError),
20
21    #[error(transparent)]
22    Policy(#[from] nexql_policy::PolicyError),
23
24    #[error(transparent)]
25    Index(#[from] nexql_index::IndexError),
26
27    #[error("postgres error: {}", format_postgres_error(.0))]
28    Postgres(#[from] tokio_postgres::Error),
29}