subsoil/database/error.rs
1// This file is part of Soil.
2
3// Copyright (C) Soil contributors.
4// Copyright (C) Parity Technologies (UK) Ltd.
5// SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later WITH Classpath-exception-2.0
6
7/// The error type for database operations.
8#[derive(Debug)]
9pub struct DatabaseError(pub Box<dyn std::error::Error + Send + Sync + 'static>);
10
11impl std::fmt::Display for DatabaseError {
12 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
13 write!(f, "{}", self.0)
14 }
15}
16
17impl std::error::Error for DatabaseError {
18 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
19 None
20 }
21}
22
23/// A specialized `Result` type for database operations.
24pub type Result<T> = std::result::Result<T, DatabaseError>;