Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit 9b07e03

Browse files
committed
Migrate to unified error type
1 parent 469d91f commit 9b07e03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+871
-613
lines changed

Cargo.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripty_audio_handler/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ async-trait.workspace = true
2424
scripty_db = { path = "../scripty_db" }
2525
scripty_stt = { path = "../scripty_stt" }
2626
#scripty_tts = { path = "../scripty_tts" }
27+
scripty_error = { path = "../scripty_error" }
2728
scripty_utils = { path = "../scripty_utils" }
2829
scripty_redis = { path = "../scripty_redis" }
2930
scripty_automod = { path = "../scripty_automod" }

scripty_audio_handler/src/audio_handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use ahash::RandomState;
1111
use dashmap::{DashMap, DashSet};
1212
use scripty_automod::types::AutomodServerConfig;
1313
use scripty_data_type::{CallDeath, get_data};
14+
use scripty_error::Error;
1415
use scripty_integrations::kiai::KiaiApiClient;
1516
use serenity::{
1617
builder::ExecuteWebhook,
@@ -23,7 +24,6 @@ use serenity::{
2324
use songbird::{Event, EventContext, EventHandler};
2425

2526
use crate::{
26-
error::Error,
2727
events::{
2828
VoiceTickContext,
2929
client_disconnect,
@@ -113,7 +113,7 @@ impl AudioHandler {
113113
guild_id,
114114
voice_channel_id,
115115
)
116-
.ok_or_else(Error::already_exists)?;
116+
.ok_or_else(Error::call_already_exists)?;
117117

118118
let this = Self {
119119
ssrc_state,

scripty_audio_handler/src/connect.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use ahash::RandomState;
22
use dashmap::DashMap;
33
use scripty_data_type::get_data;
4+
use scripty_error::Error;
45
use scripty_premium::PremiumTierList;
56
use serenity::{
67
builder::{CreateWebhook, ExecuteWebhook},
@@ -12,8 +13,6 @@ use serenity::{
1213
};
1314
use songbird::{CoreEvent, error::JoinError, events::Event};
1415

15-
use crate::Error;
16-
1716
/// Kick off the process of connecting Scripty to a voice channel.
1817
///
1918
/// # Arguments
@@ -46,7 +45,7 @@ pub async fn connect_to_vc(
4645
if existing_id == voice_channel_id {
4746
// attempting to rejoin the same channel, so return early
4847
debug!(%voice_channel_id, %guild_id, "attempting to rejoin the same channel that we were already in, refusing to do so");
49-
return Err(Error::already_exists());
48+
return Err(Error::call_already_exists());
5049
}
5150
}
5251

@@ -111,7 +110,7 @@ pub async fn connect_to_vc(
111110
}
112111
};
113112
let Some(ref webhook_token) = webhook.token else {
114-
return Err(Error::no_webhook_token());
113+
return Err(Error::expected_webhook_token());
115114
};
116115
let webhook_id = webhook.id;
117116

scripty_audio_handler/src/disconnect.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ use std::time::Duration;
22

33
use dashmap::DashMap;
44
use scripty_data_type::get_data;
5+
use scripty_error::Error;
56
use serenity::{gateway::client::Context, model::id::GuildId};
67
use songbird::error::JoinError;
78

8-
use crate::error::Error;
9-
109
pub async fn disconnect_from_vc(ctx: &Context, guild_id: GuildId) -> Result<bool, Error> {
1110
let sb = crate::get_songbird();
1211
let res = match sb.remove(guild_id).await {

scripty_audio_handler/src/error.rs

Lines changed: 0 additions & 112 deletions
This file was deleted.

scripty_audio_handler/src/events/driver_disconnect.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use songbird::{events::context_data::DisconnectReason, id::GuildId, model::Close
1212

1313
use crate::{
1414
connect_to_vc,
15-
error::ErrorKind,
1615
types::{SeenUsers, TranscriptResults},
1716
};
1817

@@ -93,7 +92,7 @@ pub async fn driver_disconnect(
9392
tokio::time::sleep(std::time::Duration::from_secs(30)).await;
9493
debug!(?guild_id, "attempting reconnect");
9594

96-
if let Err(ErrorKind::Join(e)) = connect_to_vc(
95+
if let Err(e) = connect_to_vc(
9796
ctx2,
9897
serenity::all::GuildId::new(guild_id.get()),
9998
channel_id,
@@ -102,16 +101,13 @@ pub async fn driver_disconnect(
102101
record_transcriptions,
103102
ephemeral,
104103
)
105-
.await
106-
.map_err(|x| x.kind)
107-
&& let Err(e) = webhook2
108-
.execute(
109-
&ctx3.http,
110-
false,
111-
ExecuteWebhook::default()
112-
.content(format!("Failed to reconnect due to: {}", e)),
113-
)
114-
.await
104+
.await && let Err(e) = webhook2
105+
.execute(
106+
&ctx3.http,
107+
false,
108+
ExecuteWebhook::default().content(format!("Failed to reconnect due to: {}", e)),
109+
)
110+
.await
115111
{
116112
debug!(
117113
?guild_id,

0 commit comments

Comments
 (0)