1use url::Url;
4
5#[derive(Debug, thiserror::Error)]
7pub enum Error {
8 #[error(transparent)]
10 Load {
11 #[from]
12 source: crate::loader::Error,
13 },
14 #[error("Error in parsing `{plugin_name}` configuration from `{url}` for `{item}`")]
16 Parse {
17 plugin_name: String,
18 url: Url,
19 item: Box<String>,
20 source: crate::parser::Error,
21 },
22 #[error(transparent)]
24 Validate {
25 #[from]
26 source: plugx_input::schema::InputSchemaError,
27 },
28 #[error(transparent)]
29 Other(#[from] anyhow::Error),
30}
31
32impl From<url::ParseError> for Error {
33 fn from(url_parser_error: url::ParseError) -> Self {
34 Self::Other(anyhow::anyhow!(url_parser_error))
35 }
36}
37
38impl From<(String, Url, String, crate::parser::Error)> for Error {
39 fn from(
40 (plugin_name, url, item, parser_error): (String, Url, String, crate::parser::Error),
41 ) -> Self {
42 Self::Parse {
43 plugin_name,
44 url,
45 item: Box::new(item),
46 source: parser_error,
47 }
48 }
49}