rust_wistia/models/
error.rs1use hyper::http::uri::InvalidUri;
4
5use std::io;
6
7use serde::{Deserialize, Serialize};
8use thiserror::Error;
9
10#[derive(Debug, Error)]
17#[non_exhaustive]
18pub enum RustWistiaError {
19 #[error("no such file: the source file path `{0}` should exist")]
20 FileNotFound(String),
21 #[error("environment variable `{name}` must be set")]
22 EnvVarNotFound { name: String },
23 #[error("{video_id}: no such asset ({r#type}) for video.\n Valid Assets: {valid_types:?}")]
25 AssetNotFound {
26 r#type: String,
27 video_id: String,
28 valid_types: Vec<String>,
29 },
30 #[error("An argument for `media_id` or `media` is required.")]
32 MediaIsRequired,
33 #[error(
47 "invalid request\n status: {status_code:?})\n reason: {reason}\n error: {error:#?}"
48 )]
49 Request {
50 status_code: u16,
51 reason: String,
52 error: WistiaError,
53 },
54 #[error("unknown rust-wistia error")]
55 Unknown,
56 #[error(transparent)]
58 Io(#[from] io::Error),
59 #[error(transparent)]
60 Hyper(#[from] hyper::Error),
61 #[error(transparent)]
62 Http(#[from] hyper::http::Error),
63 #[error(transparent)]
64 InvalidUri(#[from] InvalidUri),
65 #[error(transparent)]
66 SerdeJson(#[from] serde_json::Error),
67 #[error(transparent)]
68 SerdeUrlEncodedSer(#[from] serde_urlencoded::ser::Error),
69}
70
71#[derive(Debug, Default, Deserialize, Serialize)]
75pub struct WistiaError {
76 #[serde(default)]
77 #[serde(rename = "error")]
78 pub message: String,
79 pub code: Option<String>,
80 pub detail: Option<String>,
81}