github_workflows_update/
error.rs

1// Copyright (C) 2022 Leandro Lisboa Penz <lpenz@lpenz.org>
2// This file is subject to the terms and conditions defined in
3// file 'LICENSE', which is part of this source code package.
4
5//! [`Error`] and [`Result`] types.
6
7use reqwest;
8use serde_json;
9use url;
10
11use thiserror;
12
13pub type Result<T, E = Error> = core::result::Result<T, E>;
14
15#[derive(thiserror::Error, Debug)]
16pub enum Error {
17    #[error("could not parse resource {0}")]
18    ResourceParseError(String),
19    #[error("unable to parse version in {0}")]
20    VersionParsing(String),
21    #[error("{1} while getting {0}")]
22    HttpError(url::Url, reqwest::StatusCode),
23    #[error("{0} while parsing json")]
24    JsonParsing(String),
25
26    // Forwarded errors
27    #[error(transparent)]
28    JsonError(#[from] serde_json::Error),
29    #[error(transparent)]
30    ReqwestError(#[from] reqwest::Error),
31    #[error(transparent)]
32    UrlParseError(#[from] url::ParseError),
33}