updatehub_sdk/
error.rs

1// Copyright (C) 2019 O.S. Systems Sofware LTDA
2//
3// SPDX-License-Identifier: Apache-2.0
4
5use derive_more::{Display, Error, From};
6
7/// Type alias of `Result` where the `Err` is a `updatehub_sdk::Error`.
8pub type Result<A> = std::result::Result<A, Error>;
9
10/// UpdateHub SDK error type.
11#[derive(Debug, Display, Error, From)]
12pub enum Error {
13    #[display(fmt = "Agent is busy: {:?}", _0)]
14    AgentIsBusy(#[error(not(source))] crate::api::state::Response),
15
16    #[display(fmt = "Abort download was refused: {:?}", _0)]
17    AbortDownloadRefused(#[error(not(source))] crate::api::abort_download::Refused),
18
19    #[display(fmt = "Unexpected response: {:?}", _0)]
20    UnexpectedResponse(#[error(not(source))] reqwest::StatusCode),
21
22    Client(reqwest::Error),
23
24    Io(std::io::Error),
25
26    Env(std::env::VarError),
27}