1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
use std::fmt::{Debug, Display, Formatter};
use std::io::Write;
use std::error::Error;
#[derive(Debug)]
pub enum ArrowError {
NotYetImplemented(String),
ExternalError(Box<dyn Error + Send + Sync>),
CastError(String),
MemoryError(String),
ParseError(String),
SchemaError(String),
ComputeError(String),
DivideByZero,
CsvError(String),
JsonError(String),
IoError(String),
InvalidArgumentError(String),
ParquetError(String),
CDataInterface(String),
DictionaryKeyOverflowError,
}
impl ArrowError {
pub fn from_external_error(error: Box<dyn Error + Send + Sync>) -> Self {
Self::ExternalError(error)
}
}
impl From<std::io::Error> for ArrowError {
fn from(error: std::io::Error) -> Self {
ArrowError::IoError(error.to_string())
}
}
impl From<std::string::FromUtf8Error> for ArrowError {
fn from(error: std::string::FromUtf8Error) -> Self {
ArrowError::ParseError(error.to_string())
}
}
impl<W: Write> From<std::io::IntoInnerError<W>> for ArrowError {
fn from(error: std::io::IntoInnerError<W>) -> Self {
ArrowError::IoError(error.to_string())
}
}
impl Display for ArrowError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
ArrowError::NotYetImplemented(source) => {
write!(f, "Not yet implemented: {}", &source)
}
ArrowError::ExternalError(source) => write!(f, "External error: {}", &source),
ArrowError::CastError(desc) => write!(f, "Cast error: {}", desc),
ArrowError::MemoryError(desc) => write!(f, "Memory error: {}", desc),
ArrowError::ParseError(desc) => write!(f, "Parser error: {}", desc),
ArrowError::SchemaError(desc) => write!(f, "Schema error: {}", desc),
ArrowError::ComputeError(desc) => write!(f, "Compute error: {}", desc),
ArrowError::DivideByZero => write!(f, "Divide by zero error"),
ArrowError::CsvError(desc) => write!(f, "Csv error: {}", desc),
ArrowError::JsonError(desc) => write!(f, "Json error: {}", desc),
ArrowError::IoError(desc) => write!(f, "Io error: {}", desc),
ArrowError::InvalidArgumentError(desc) => {
write!(f, "Invalid argument error: {}", desc)
}
ArrowError::ParquetError(desc) => {
write!(f, "Parquet argument error: {}", desc)
}
ArrowError::CDataInterface(desc) => {
write!(f, "C Data interface error: {}", desc)
}
ArrowError::DictionaryKeyOverflowError => {
write!(f, "Dictionary key bigger than the key type")
}
}
}
}
impl Error for ArrowError {}