Skip to main content

dataplane_sdk/core/
error.rs

1//  Copyright (c) 2026 Metaform Systems, Inc
2//
3//  This program and the accompanying materials are made available under the
4//  terms of the Apache License, Version 2.0 which is available at
5//  https://www.apache.org/licenses/LICENSE-2.0
6//
7//    SPDX-License-Identifier: Apache-2.0
8//
9//    Contributors:
10//         Metaform Systems, Inc. - initial API and implementation
11//
12
13pub type DbResult<T> = Result<T, DbError>;
14pub type HandlerResult<T> = Result<T, HandlerError>;
15
16#[derive(Debug, thiserror::Error)]
17pub enum HandlerError {
18    #[error("Database connection error: {0}")]
19    Generic(Box<dyn std::error::Error + Send + Sync>),
20    #[error("Not supported: {0}")]
21    NotSupported(String),
22}
23
24#[derive(Debug, thiserror::Error)]
25pub enum DbError {
26    #[error("Database connection error: {0}")]
27    Generic(Box<dyn std::error::Error + Send + Sync>),
28    #[error("Not found: {0}")]
29    NotFound(String),
30    #[error("Already exists: {0}")]
31    AlreadyExists(String),
32}