diff --git a/Cargo.lock b/Cargo.lock index b7e05bf..379a64c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -260,6 +260,16 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "better-panic" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fa9e1d11a268684cbd90ed36370d7577afb6c62d912ddff5c15fc34343e5036" +dependencies = [ + "backtrace", + "console", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -493,6 +503,18 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "console" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "windows-sys 0.59.0", +] + [[package]] name = "contextual" version = "0.1.6" @@ -882,6 +904,12 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + [[package]] name = "encoding_rs" version = "0.8.35" @@ -955,6 +983,7 @@ version = "0.1.0" dependencies = [ "async-openai", "bandcamp", + "better-panic", "chrono", "color-eyre", "crossterm", @@ -5140,6 +5169,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.60.2" diff --git a/Cargo.toml b/Cargo.toml index 8b0ebe3..7ef3005 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2024" [dependencies] async-openai = { version = "0.40.2", features = ["completions", "full"] } bandcamp = "0.3.4" +better-panic = "0.3.0" chrono = { version = "0.4.44", features = ["serde"] } color-eyre = "0.6.5" crossterm = { version = "0.29.0", features = ["event-stream"] } diff --git a/src/main.rs b/src/main.rs index 7a36e0e..556abc7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,7 +14,7 @@ use futures::{StreamExt, future::FutureExt}; use ratatui::prelude::*; -use crate::{events::AudioRecordRequest, prediction::{PossibleResponse}, scene::{ConversationEntry, PlaylistEntry, Scene, StageActions, StageDirection}, tts::start_tts}; +use crate::{events::AudioRecordRequest, prediction::PossibleResponse, scene::{ConversationEntry, PlaylistEntry, Scene, StageActions, StageDirection}, tts::start_tts}; mod scene; mod events; @@ -436,6 +436,7 @@ impl App { self.scene.conversation_mut().append(&mut actions.additions.clone()); self.prediction_request_sink.send(actions).unwrap(); self.is_requesting = true; + panic!("at the disco"); } fn reload_mixxx_playlist(&mut self) { @@ -481,7 +482,16 @@ impl SaveData { #[tokio::main] async fn main() { - color_eyre::install().unwrap(); + let (panic_hook, eyre_hook) = color_eyre::config::HookBuilder::default() + .display_env_section(true) + .display_location_section(true) + .into_hooks(); + eyre_hook.install().unwrap(); + + std::panic::set_hook(Box::new(move |panic_info| { + let msg = format!("{}", panic_hook.panic_report(panic_info)); + println!("Panic: {}", msg); + })); if option_env!("OPENAI_API_KEY").is_none() { eprintln!("Error: OPENAI_API_KEY environment variable not set. The application will not function without it.");