async_graphql_dataloader/
error.rs1use std::fmt;
3
4#[derive(Debug, Clone)]
5pub enum DataLoaderError {
6 ChannelClosed,
7 BatchError(String),
8 KeyNotFound,
9 Timeout,
10}
11
12impl fmt::Display for DataLoaderError {
13 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14 match self {
15 DataLoaderError::ChannelClosed => {
16 write!(f, "Channel closed while waiting for batch result")
17 }
18 DataLoaderError::BatchError(msg) => write!(f, "Batch load error: {}", msg),
19 DataLoaderError::KeyNotFound => write!(f, "Key not found in batch results"),
20 DataLoaderError::Timeout => write!(f, "Timeout waiting for batch"),
21 }
22 }
23}
24
25impl std::error::Error for DataLoaderError {}
26
27impl From<String> for DataLoaderError {
28 fn from(err: String) -> Self {
29 DataLoaderError::BatchError(err)
30 }
31}