Skip to main content

latchlm_core/
error.rs

1// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
2// If a copy of the MPL was not distributed with this file, You can obtain one at
3// https://mozilla.org/MPL/2.0/.
4
5//! Crate-wide error definitions.
6//!
7//! This module defines a unified `Error` enum used throughout the crate.
8
9#[non_exhaustive]
10#[derive(thiserror::Error, Debug)]
11pub enum Error {
12    #[error("Request failed: {0}")]
13    RequestError(#[from] reqwest::Error),
14
15    #[error("Api error: {status} - {message} ")]
16    ApiError { status: u16, message: String },
17
18    #[error("Failed to parse the response")]
19    ParseError(#[from] serde_json::Error),
20
21    #[error("Invalid model name: {0}")]
22    InvalidModelError(String),
23
24    #[error("Provider settings error: {provider} : {error}")]
25    ProviderError { provider: String, error: String },
26}
27
28pub type Result<T> = std::result::Result<T, Error>;