aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/error.rs4
-rw-r--r--src/client/mod.rs37
2 files changed, 39 insertions, 2 deletions
diff --git a/src/client/error.rs b/src/client/error.rs
index a08d15b..1a23599 100644
--- a/src/client/error.rs
+++ b/src/client/error.rs
@@ -21,6 +21,9 @@ pub enum Error {
/// When a shard has completely failed to reboot after resume and/or
/// reconnect attempts.
ShardBootFailure,
+ /// When all shards that the client is responsible for have shutdown with an
+ /// error.
+ Shutdown,
}
impl Display for Error {
@@ -34,6 +37,7 @@ impl StdError for Error {
match *self {
Error::InvalidToken => "The provided token was invalid",
Error::ShardBootFailure => "Failed to (re-)boot a shard",
+ Error::Shutdown => "The clients shards shutdown",
}
}
}
diff --git a/src/client/mod.rs b/src/client/mod.rs
index ff5e4bd..f728792 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -347,6 +347,12 @@ impl Client {
/// # }
/// ```
///
+ /// # Errors
+ ///
+ /// Returns a [`ClientError::Shutdown`] when all shards have shutdown due to
+ /// an error.
+ ///
+ /// [`ClientError::Shutdown`]: enum.ClientError.html#variant.Shutdown
/// [gateway docs]: gateway/index.html#sharding
pub fn start_autosharded(&mut self) -> Result<()> {
let mut res = http::get_bot_gateway()?;
@@ -419,6 +425,12 @@ impl Client {
/// # }
/// ```
///
+ /// # Errors
+ ///
+ /// Returns a [`ClientError::Shutdown`] when all shards have shutdown due to
+ /// an error.
+ ///
+ /// [`ClientError::Shutdown`]: enum.ClientError.html#variant.Shutdown
/// [`start`]: #method.start
/// [`start_autosharded`]: #method.start_autosharded
/// [gateway docs]: gateway/index.html#sharding
@@ -462,6 +474,12 @@ impl Client {
/// # }
/// ```
///
+ /// # Errors
+ ///
+ /// Returns a [`ClientError::Shutdown`] when all shards have shutdown due to
+ /// an error.
+ ///
+ /// [`ClientError::Shutdown`]: enum.ClientError.html#variant.Shutdown
/// [`start_shard`]: #method.start_shard
/// [`start_shard_range`]: #method.start_shard_range
/// [Gateway docs]: gateway/index.html#sharding
@@ -516,6 +534,13 @@ impl Client {
/// # }
/// ```
///
+ /// # Errors
+ ///
+ /// Returns a [`ClientError::Shutdown`] when all shards have shutdown due to
+ /// an error.
+ ///
+ ///
+ /// [`ClientError::Shutdown`]: enum.ClientError.html#variant.Shutdown
/// [`start_shard`]: #method.start_shard
/// [`start_shards`]: #method.start_shards
/// [Gateway docs]: gateway/index.html#sharding
@@ -919,7 +944,15 @@ impl Client {
// 2: total number of shards the bot is sharding for
//
// Not all shards need to be initialized in this process.
- fn start_connection(&mut self, shard_data: Option<[u64; 3]>, url: String) -> Result<()> {
+ //
+ // # Errors
+ //
+ // Returns a [`ClientError::Shutdown`] when all shards have shutdown due to
+ // an error.
+ //
+ // [`ClientError::Shutdown`]: enum.ClientError.html#variant.Shutdown
+ fn start_connection(&mut self, shard_data: Option<[u64; 3]>, url: String)
+ -> Result<()> {
// Update the framework's current user if the feature is enabled.
//
// This also acts as a form of check to ensure the token is correct.
@@ -1012,7 +1045,7 @@ impl Client {
let _ = thread.join();
}
- Ok(())
+ Err(Error::Client(ClientError::Shutdown))
}
}