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.
This commit is contained in:
2025-04-05 17:05:10 -05:00
parent e1da535dc2
commit 42502694f3
2 changed files with 9 additions and 8 deletions

7
src/error.rs Normal file
View File

@@ -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),
}

View File

@@ -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<u8>,
}
#[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<Self, InitError> {
let client = MeilisearchClient::try_from(config)?;