remove Error::is_runtime_startup accessor
This commit is contained in:
@@ -504,7 +504,7 @@ impl ClientHandle {
|
|||||||
match spawn_rx.wait() {
|
match spawn_rx.wait() {
|
||||||
Ok(Ok(())) => (),
|
Ok(Ok(())) => (),
|
||||||
Ok(Err(err)) => return Err(err),
|
Ok(Err(err)) => return Err(err),
|
||||||
Err(_canceled) => return Err(::error::runtime_startup()),
|
Err(_canceled) => event_loop_panicked(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -537,14 +537,7 @@ impl ClientHandle {
|
|||||||
Either::B(future::ok(()))
|
Either::B(future::ok(()))
|
||||||
};
|
};
|
||||||
|
|
||||||
let rx = rx.map_err(|_canceled| {
|
let rx = rx.map_err(|_canceled| event_loop_panicked());
|
||||||
// The only possible reason there would be a Canceled error
|
|
||||||
// is if the thread running the event loop panicked. We could return
|
|
||||||
// an Err here, like a BrokenPipe, but the Client is not
|
|
||||||
// recoverable. Additionally, the panic in the other thread
|
|
||||||
// is not normal, and should likely be propagated.
|
|
||||||
panic!("event loop thread panicked");
|
|
||||||
});
|
|
||||||
|
|
||||||
let fut = write.join(rx).map(|((), res)| res);
|
let fut = write.join(rx).map(|((), res)| res);
|
||||||
|
|
||||||
@@ -578,3 +571,14 @@ impl KeepCoreThreadAlive {
|
|||||||
KeepCoreThreadAlive(None)
|
KeepCoreThreadAlive(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cold]
|
||||||
|
#[inline(never)]
|
||||||
|
fn event_loop_panicked() -> ! {
|
||||||
|
// The only possible reason there would be a Canceled error
|
||||||
|
// is if the thread running the event loop panicked. We could return
|
||||||
|
// an Err here, like a BrokenPipe, but the Client is not
|
||||||
|
// recoverable. Additionally, the panic in the other thread
|
||||||
|
// is not normal, and should likely be propagated.
|
||||||
|
panic!("event loop thread panicked");
|
||||||
|
}
|
||||||
|
|||||||
21
src/error.rs
21
src/error.rs
@@ -147,8 +147,7 @@ impl Error {
|
|||||||
Kind::TooManyRedirects |
|
Kind::TooManyRedirects |
|
||||||
Kind::RedirectLoop |
|
Kind::RedirectLoop |
|
||||||
Kind::ClientError(_) |
|
Kind::ClientError(_) |
|
||||||
Kind::ServerError(_) |
|
Kind::ServerError(_) => None,
|
||||||
Kind::RuntimeStartupFailure => None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,14 +208,6 @@ impl Error {
|
|||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if this error is due to a failure starting the runtime.
|
|
||||||
pub fn is_runtime_startup(&self) -> bool {
|
|
||||||
match self.inner.kind {
|
|
||||||
Kind::RuntimeStartupFailure => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Error {
|
impl fmt::Debug for Error {
|
||||||
@@ -259,7 +250,6 @@ impl fmt::Display for Error {
|
|||||||
f.write_str("Server Error: ")?;
|
f.write_str("Server Error: ")?;
|
||||||
fmt::Display::fmt(code, f)
|
fmt::Display::fmt(code, f)
|
||||||
}
|
}
|
||||||
Kind::RuntimeStartupFailure => f.write_str("Client runtime failed to start"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,7 +275,6 @@ impl StdError for Error {
|
|||||||
Kind::RedirectLoop => "Infinite redirect loop",
|
Kind::RedirectLoop => "Infinite redirect loop",
|
||||||
Kind::ClientError(_) => "Client Error",
|
Kind::ClientError(_) => "Client Error",
|
||||||
Kind::ServerError(_) => "Server Error",
|
Kind::ServerError(_) => "Server Error",
|
||||||
Kind::RuntimeStartupFailure => "Client runtime failed to start",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,8 +298,7 @@ impl StdError for Error {
|
|||||||
Kind::TooManyRedirects |
|
Kind::TooManyRedirects |
|
||||||
Kind::RedirectLoop |
|
Kind::RedirectLoop |
|
||||||
Kind::ClientError(_) |
|
Kind::ClientError(_) |
|
||||||
Kind::ServerError(_) |
|
Kind::ServerError(_) => None,
|
||||||
Kind::RuntimeStartupFailure => None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -335,7 +323,6 @@ pub(crate) enum Kind {
|
|||||||
RedirectLoop,
|
RedirectLoop,
|
||||||
ClientError(StatusCode),
|
ClientError(StatusCode),
|
||||||
ServerError(StatusCode),
|
ServerError(StatusCode),
|
||||||
RuntimeStartupFailure,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -502,10 +489,6 @@ pub(crate) fn url_bad_scheme(url: Url) -> Error {
|
|||||||
Error::new(Kind::UrlBadScheme, Some(url))
|
Error::new(Kind::UrlBadScheme, Some(url))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn runtime_startup() -> Error {
|
|
||||||
Error::new(Kind::RuntimeStartupFailure, None)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
Reference in New Issue
Block a user