-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update edgelet to use tokio 1 (#5385)
Updates aziot-edged's tokio dependency from 0.1 to 1.
- Loading branch information
1 parent
2e04730
commit 4c2f173
Showing
361 changed files
with
15,125 additions
and
36,877 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,113 +1,55 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
use std::fmt::{self, Display}; | ||
use std::io; | ||
|
||
use failure::{Backtrace, Context, Fail}; | ||
use thiserror::Error as ThisError; | ||
use hyper::Error as HyperError; | ||
use serde_json; | ||
use url::ParseError; | ||
|
||
use edgelet_http::Error as EdgeletHttpError; | ||
use workload::apis::Error as WorkloadError; | ||
|
||
#[derive(Debug)] | ||
pub struct Error { | ||
inner: Context<ErrorKind>, | ||
use chrono::ParseError; | ||
use edgelet_client::Error as ClientError; | ||
use edgelet_client::WorkloadError; | ||
|
||
|
||
|
||
#[derive(Debug, ThisError)] | ||
pub enum Error { | ||
|
||
#[error("no value for required '{0}'")] | ||
MissingVal(&'static str), | ||
#[error("Hyper error")] | ||
Hyper( | ||
#[from] | ||
#[source] | ||
HyperError, | ||
), | ||
#[error("An IO error occurred.")] | ||
Io( | ||
#[from] | ||
#[source] | ||
io::Error, | ||
), | ||
#[error("Chrono date parse error")] | ||
Parse( | ||
#[from] | ||
#[source] | ||
ParseError, | ||
), | ||
#[error("Serde error")] | ||
Serde( | ||
#[from] | ||
#[source] | ||
serde_json::Error, | ||
), | ||
#[error("Edgelet client error")] | ||
Client( | ||
#[from] | ||
#[source] | ||
ClientError, | ||
), | ||
#[error("Workload api error")] | ||
Workload( | ||
#[from] | ||
#[source] | ||
WorkloadError, | ||
), | ||
} | ||
|
||
#[derive(Debug, Fail)] | ||
pub enum ErrorKind { | ||
#[fail(display = "Client error")] | ||
Client(WorkloadError<serde_json::Value>), | ||
#[fail(display = "Error connecting to endpoint")] | ||
Http, | ||
#[fail(display = "Hyper error")] | ||
Hyper, | ||
#[fail(display = "An IO error occurred.")] | ||
Io, | ||
#[fail(display = "Url parse error")] | ||
Parse, | ||
#[fail(display = "Serde error")] | ||
Serde, | ||
} | ||
|
||
impl Fail for Error { | ||
fn cause(&self) -> Option<&dyn Fail> { | ||
self.inner.cause() | ||
} | ||
|
||
fn backtrace(&self) -> Option<&Backtrace> { | ||
self.inner.backtrace() | ||
} | ||
} | ||
|
||
impl Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
Display::fmt(&self.inner, f) | ||
} | ||
} | ||
|
||
impl From<ErrorKind> for Error { | ||
fn from(kind: ErrorKind) -> Self { | ||
Error { | ||
inner: Context::new(kind), | ||
} | ||
} | ||
} | ||
|
||
impl From<Context<ErrorKind>> for Error { | ||
fn from(inner: Context<ErrorKind>) -> Self { | ||
Error { inner } | ||
} | ||
} | ||
|
||
impl From<io::Error> for Error { | ||
fn from(error: io::Error) -> Self { | ||
Error { | ||
inner: error.context(ErrorKind::Io), | ||
} | ||
} | ||
} | ||
|
||
impl From<EdgeletHttpError> for Error { | ||
fn from(error: EdgeletHttpError) -> Self { | ||
Error { | ||
inner: error.context(ErrorKind::Http), | ||
} | ||
} | ||
} | ||
|
||
impl From<HyperError> for Error { | ||
fn from(error: HyperError) -> Self { | ||
Error { | ||
inner: error.context(ErrorKind::Hyper), | ||
} | ||
} | ||
} | ||
|
||
impl From<ParseError> for Error { | ||
fn from(error: ParseError) -> Self { | ||
Error { | ||
inner: error.context(ErrorKind::Parse), | ||
} | ||
} | ||
} | ||
|
||
impl From<serde_json::Error> for Error { | ||
fn from(error: serde_json::Error) -> Self { | ||
Error { | ||
inner: error.context(ErrorKind::Serde), | ||
} | ||
} | ||
} | ||
|
||
impl From<WorkloadError<serde_json::Value>> for Error { | ||
fn from(error: WorkloadError<serde_json::Value>) -> Self { | ||
match error { | ||
WorkloadError::Hyper(h) => From::from(h), | ||
WorkloadError::Serde(s) => From::from(s), | ||
WorkloadError::Api(_) => From::from(ErrorKind::Client(error)), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.