chore: removed anyhow from apperror for improved error handling

This commit is contained in:
Per Stark
2026-05-27 13:33:02 +02:00
parent 76fcdcd6ce
commit e2284b1e69
7 changed files with 36 additions and 25 deletions
@@ -1,4 +1,3 @@
use anyhow::anyhow;
use common::{
error::AppError,
storage::{db::SurrealDbClient, store::StorageManager, types::file_info::FileInfo},
@@ -78,7 +77,7 @@ pub async fn extract_text_from_file(
let file_bytes = storage
.get(&file_info.path)
.await
.map_err(|e| AppError::from(anyhow!(e)))?;
.map_err(AppError::Storage)?;
let local_path = resolve_existing_local_path(storage, &file_info.path).await;
match file_info.mime_type.as_str() {
@@ -30,24 +30,36 @@ pub async fn extract_text_from_url(
.sandbox(false)
.build()
.map_err(|e| AppError::InternalError(e.to_string()))?;
Browser::new(options)?
Browser::new(options)
.map_err(|e| AppError::InternalError(e.to_string()))?
}
#[cfg(not(feature = "docker"))]
{
Browser::default()?
Browser::default()
.map_err(|e| AppError::InternalError(e.to_string()))?
}
};
let tab = browser.new_tab()?;
let page = tab.navigate_to(url)?;
let loaded_page = page.wait_until_navigated()?;
let raw_content = loaded_page.get_content()?;
let screenshot = loaded_page.capture_screenshot(
headless_chrome::protocol::cdp::Page::CaptureScreenshotFormatOption::Jpeg,
None,
None,
true,
)?;
let tab = browser
.new_tab()
.map_err(|e| AppError::InternalError(e.to_string()))?;
let page = tab
.navigate_to(url)
.map_err(|e| AppError::InternalError(e.to_string()))?;
let loaded_page = page
.wait_until_navigated()
.map_err(|e| AppError::InternalError(e.to_string()))?;
let raw_content = loaded_page
.get_content()
.map_err(|e| AppError::InternalError(e.to_string()))?;
let screenshot = loaded_page
.capture_screenshot(
headless_chrome::protocol::cdp::Page::CaptureScreenshotFormatOption::Jpeg,
None,
None,
true,
)
.map_err(|e| AppError::InternalError(e.to_string()))?;
let mut tmp_file = NamedTempFile::new()?;
let temp_path_str = tmp_file.path().display().to_string();