From 42502694f3c1ca8ec89800c990493ec76caa82fc Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sat, 5 Apr 2025 17:05:10 -0500 Subject: [PATCH] error: Move errors to a separate module For some reason, using the `thiserror::Error` derive macro causes the syntax highlighting to fail for the rest of the code in the file, at least in Neovim. Having all the errors in one module will consolidate this effect to that one file. --- src/error.rs | 7 +++++++ src/lib.rs | 10 ++-------- 2 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 src/error.rs diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..a7214b3 --- /dev/null +++ b/src/error.rs @@ -0,0 +1,7 @@ +#[derive(Debug, thiserror::Error)] +pub enum InitError { + #[error("Meilisearch error: {0}")] + Meilisearch(#[from] crate::meilisearch::Error), + #[error("Failed to load JWT secret: {0}")] + LoadSecret(std::io::Error), +} diff --git a/src/lib.rs b/src/lib.rs index a31f5b1..0c09d2a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ pub mod auth; pub mod config; +mod error; pub mod meilisearch; pub mod page; @@ -9,20 +10,13 @@ use rocket::Rocket; use tracing::error; use config::Config; +pub use error::InitError; pub struct Context { client: MeilisearchClient, jwt_secret: Vec, } -#[derive(Debug, thiserror::Error)] -pub enum InitError { - #[error("Meilisearch error: {0}")] - Meilisearch(#[from] meilisearch::Error), - #[error("Failed to load JWT secret: {0}")] - LoadSecret(std::io::Error), -} - impl Context { pub fn init(config: &Config) -> Result { let client = MeilisearchClient::try_from(config)?;