1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (C) 2022 Leandro Lisboa Penz <lpenz@lpenz.org>
// This file is subject to the terms and conditions defined in
// file 'LICENSE', which is part of this source code package.

//! [`Error`] and [`Result`] types.

use reqwest;
use serde_json;

use thiserror;

pub type Result<T, E = Error> = core::result::Result<T, E>;

#[derive(thiserror::Error, Debug)]
pub enum Error {
    // Own errors
    #[error("updater not found for {0}")]
    UpdaterNotFound(String),
    #[error("unable to parse version in {0}")]
    VersionParsing(String),
    #[error("{1} while getting {0}")]
    HttpError(String, reqwest::StatusCode),
    #[error("{0} while parsing json")]
    JsonParsing(String),

    // Forwarded errors
    #[error(transparent)]
    JsonError(#[from] serde_json::Error),
    #[error(transparent)]
    ReqwestError(#[from] reqwest::Error),
}