1use std::path::PathBuf;
4
5use crate::types::{TaskId, TaskStatus};
6
7pub type Result<T, E = Error> = std::result::Result<T, E>;
9
10#[derive(thiserror::Error, Debug)]
12#[non_exhaustive]
13pub enum Error {
14 #[error("HTTP {status}: {message}")]
16 Http {
17 status: u16,
19 message: String,
21 },
22
23 #[error("API [{code}] {message}{}", suggestion.as_deref().map(|s| format!(" — {s}")).unwrap_or_default())]
25 Api {
26 code: i32,
28 message: String,
30 suggestion: Option<String>,
32 },
33
34 #[error("task {0} ended with status {1:?}")]
36 TaskFailed(TaskId, TaskStatus),
37
38 #[error("timed out waiting for task {0}")]
40 WaitTimeout(TaskId),
41
42 #[error("missing API key (set TRIPO_API_KEY or pass --api-key)")]
44 MissingApiKey,
45
46 #[error("invalid API key (must start with `tsk_`)")]
48 InvalidApiKey,
49
50 #[error("file already exists: {0} (use --force to overwrite)")]
52 FileExists(PathBuf),
53
54 #[error("invalid request: {0}")]
56 InvalidRequest(String),
57
58 #[error(transparent)]
60 Io(#[from] std::io::Error),
61
62 #[error(transparent)]
64 Reqwest(#[from] reqwest::Error),
65
66 #[error(transparent)]
68 Json(#[from] serde_json::Error),
69}