Skip to main content

sui_indexer_alt_reader/
error.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use std::sync::Arc;
5
6use anyhow::anyhow;
7
8/// Error type for DataLoader implementations that wraps Arc<anyhow::Error>
9/// for efficient cloning while preserving ergonomic error handling.
10#[derive(Debug, Clone, thiserror::Error)]
11#[error(transparent)]
12pub struct Error(#[from] Arc<anyhow::Error>);
13
14impl From<anyhow::Error> for Error {
15    fn from(error: anyhow::Error) -> Self {
16        Error(Arc::new(error))
17    }
18}
19
20impl From<tonic::Status> for Error {
21    fn from(error: tonic::Status) -> Self {
22        Error(Arc::new(anyhow!(error).context("gRPC error")))
23    }
24}