main: add a custom panic hook, which tries to reset the terminal before printing logs
This commit is contained in:
Generated
+38
@@ -260,6 +260,16 @@ version = "0.22.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
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]]
|
[[package]]
|
||||||
name = "bit-set"
|
name = "bit-set"
|
||||||
version = "0.5.3"
|
version = "0.5.3"
|
||||||
@@ -493,6 +503,18 @@ dependencies = [
|
|||||||
"static_assertions",
|
"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]]
|
[[package]]
|
||||||
name = "contextual"
|
name = "contextual"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
@@ -882,6 +904,12 @@ version = "1.16.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
|
checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "encode_unicode"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "encoding_rs"
|
name = "encoding_rs"
|
||||||
version = "0.8.35"
|
version = "0.8.35"
|
||||||
@@ -955,6 +983,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"async-openai",
|
"async-openai",
|
||||||
"bandcamp",
|
"bandcamp",
|
||||||
|
"better-panic",
|
||||||
"chrono",
|
"chrono",
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
"crossterm",
|
"crossterm",
|
||||||
@@ -5140,6 +5169,15 @@ dependencies = [
|
|||||||
"windows-targets 0.52.6",
|
"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]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.60.2"
|
version = "0.60.2"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ edition = "2024"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
async-openai = { version = "0.40.2", features = ["completions", "full"] }
|
async-openai = { version = "0.40.2", features = ["completions", "full"] }
|
||||||
bandcamp = "0.3.4"
|
bandcamp = "0.3.4"
|
||||||
|
better-panic = "0.3.0"
|
||||||
chrono = { version = "0.4.44", features = ["serde"] }
|
chrono = { version = "0.4.44", features = ["serde"] }
|
||||||
color-eyre = "0.6.5"
|
color-eyre = "0.6.5"
|
||||||
crossterm = { version = "0.29.0", features = ["event-stream"] }
|
crossterm = { version = "0.29.0", features = ["event-stream"] }
|
||||||
|
|||||||
+12
-2
@@ -14,7 +14,7 @@ use futures::{StreamExt, future::FutureExt};
|
|||||||
|
|
||||||
use ratatui::prelude::*;
|
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 scene;
|
||||||
mod events;
|
mod events;
|
||||||
@@ -436,6 +436,7 @@ impl App {
|
|||||||
self.scene.conversation_mut().append(&mut actions.additions.clone());
|
self.scene.conversation_mut().append(&mut actions.additions.clone());
|
||||||
self.prediction_request_sink.send(actions).unwrap();
|
self.prediction_request_sink.send(actions).unwrap();
|
||||||
self.is_requesting = true;
|
self.is_requesting = true;
|
||||||
|
panic!("at the disco");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reload_mixxx_playlist(&mut self) {
|
fn reload_mixxx_playlist(&mut self) {
|
||||||
@@ -481,7 +482,16 @@ impl SaveData {
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn 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() {
|
if option_env!("OPENAI_API_KEY").is_none() {
|
||||||
eprintln!("Error: OPENAI_API_KEY environment variable not set. The application will not function without it.");
|
eprintln!("Error: OPENAI_API_KEY environment variable not set. The application will not function without it.");
|
||||||
|
|||||||
Reference in New Issue
Block a user