1use std::path::PathBuf;
2
3use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, Error>;
6
7#[derive(Debug, Error)]
8pub enum Error {
9 #[error("no inputs provided")]
10 EmptyInputs,
11
12 #[error("unknown column '{name}' (available: {available})")]
13 UnknownColumn { name: String, available: String },
14
15 #[error("column '{0}' appears more than once in --columns/--exclude-columns")]
16 DuplicateColumn(String),
17
18 #[error(
19 "input schemas differ: '{left}' and '{right}' do not match on field '{field}'; cat requires strictly matching schemas"
20 )]
21 SchemaMismatch {
22 left: PathBuf,
23 right: PathBuf,
24 field: String,
25 },
26
27 #[error(
28 "arrow type {data_type} in column '{column}' cannot be represented in CSV; use --format jsonl"
29 )]
30 UnsupportedCsvType { column: String, data_type: String },
31
32 #[error("--indices parse error: {0}")]
33 IndexParse(String),
34
35 #[error("index {index} is out of range for dataset with {rowcount} rows")]
36 IndexOutOfRange { index: i64, rowcount: u64 },
37
38 #[error("range {start}:{end} is empty (start > end)")]
39 EmptyRange { start: i64, end: i64 },
40
41 #[error("sample size {requested} is larger than dataset row count {rowcount}")]
42 SampleTooLarge { requested: u64, rowcount: u64 },
43
44 #[error("failed to open lance dataset at {path}")]
45 LanceOpen {
46 path: PathBuf,
47 #[source]
48 source: Box<dyn std::error::Error + Send + Sync>,
49 },
50
51 #[error("lance operation failed")]
52 Lance(#[source] Box<dyn std::error::Error + Send + Sync>),
53
54 #[error("unrecognised dataset format at {path}")]
55 UnknownFormat { path: PathBuf },
56
57 #[error("--branch/--version/--tag are only valid for Lance datasets ({path})")]
58 LanceFlagsOnNonLance { path: PathBuf },
59
60 #[error("'{command}' is only valid for Lance datasets ({path})")]
61 NotLance {
62 command: &'static str,
63 path: PathBuf,
64 },
65
66 #[error(
67 "tag '{tag}' is on branch '{tag_branch}', not '{requested_branch}'; remove --branch or pass --branch {tag_branch}"
68 )]
69 TagBranchMismatch {
70 tag: String,
71 tag_branch: String,
72 requested_branch: String,
73 },
74
75 #[error("--format is not applicable to '{command}' (it does not emit row-shaped output)")]
76 FormatNotApplicable { command: &'static str },
77
78 #[error("arrow error")]
79 Arrow(#[from] arrow_schema::ArrowError),
80
81 #[error("io error")]
82 Io(#[from] std::io::Error),
83
84 #[error("csv writer error")]
85 Csv(#[from] csv::Error),
86
87 #[error("json serialization error")]
88 Json(#[from] serde_json::Error),
89}