mirror of
https://github.com/modrinth/code.git
synced 2026-09-02 13:05:50 +00:00
refactor: labrinth ApiError and error reporting (#6981)
* refactor: labrinth `ApiError` and error reporting * fix clippy * fix ci
This commit is contained in:
@@ -4,6 +4,8 @@ use crate::models::ids::{ProjectId, VersionId};
|
||||
use crate::models::projects::DependencyType;
|
||||
use crate::queue::server_ping;
|
||||
use crate::routes::ApiError;
|
||||
use crate::util::error::ApiContext as _;
|
||||
use crate::util::error::Context as _;
|
||||
use crate::{database::PgPool, env::ENV};
|
||||
use ariadne::ids::base62_impl::parse_base62;
|
||||
use async_trait::async_trait;
|
||||
@@ -94,10 +96,13 @@ pub trait SearchBackend: Send + Sync {
|
||||
info: &SearchRequest,
|
||||
redis: &RedisPool,
|
||||
) -> Result<SearchResults, ApiError> {
|
||||
let mut results = self.search_for_project_raw(info).await?;
|
||||
let mut results = self
|
||||
.search_for_project_raw(info)
|
||||
.await
|
||||
.wrap_api_err("searching projects")?;
|
||||
hydrate_search_results(&mut results.hits, redis)
|
||||
.await
|
||||
.map_err(ApiError::Internal)?;
|
||||
.wrap_internal_err("hydrating search results from database")?;
|
||||
Ok(results)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user