From ff6e4a57043d7023bf13faea1b1a540032cdc468 Mon Sep 17 00:00:00 2001 From: Orual Date: Mon, 10 Aug 2026 09:07:19 -0400 Subject: [PATCH] PM-84: eliminate all stringified errors from renderer-worker --- crates/polymodel-renderer-worker/src/lib.rs | 34 ++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/crates/polymodel-renderer-worker/src/lib.rs b/crates/polymodel-renderer-worker/src/lib.rs index c7cdcb4..9d90d67 100644 --- a/crates/polymodel-renderer-worker/src/lib.rs +++ b/crates/polymodel-renderer-worker/src/lib.rs @@ -178,12 +178,12 @@ pub enum RendererError { TextureDecode(String), #[error("parse/adaptation failure: {0}")] ParseAdaptation(&'static str), -} - -impl From for String { - fn from(error: RendererError) -> Self { - error.to_string() - } + #[error("parse/adaptation failure: {0}")] + ParseMessage(String), + #[error("I/O failure: {0}")] + Io(String), + #[error("external runtime failure: {0}")] + External(String), } impl RendererError { @@ -1453,7 +1453,7 @@ pub struct SceneVariantBinding { } impl SceneVariantBinding { - pub fn for_case(case_id: &str) -> Result { + pub fn for_case(case_id: &str) -> Result { let reflected = case_id.starts_with("reflected_"); let variant_id = if reflected { "reflected" } else { "identity" }; Ok(Self { @@ -1826,7 +1826,7 @@ pub fn semantic_counts(semantic: &LdMeshSemantic) -> (u64, u64) { fn official_texture_resources( closure: &polymodel_ldraw_core::ResourceClosure, materializations: &[Materialization], -) -> Result, String> { +) -> Result, RendererError> { let mut resources = Vec::new(); for dependency in closure.texture_dependencies() { let Some(materialization) = materializations.iter().find(|materialization| { @@ -1862,7 +1862,7 @@ fn official_texture_resources( pub fn prepare_preview_scene( input: &std::path::Path, library_root: &std::path::Path, -) -> Result { +) -> Result { use polymodel_ldraw_core::{ AdapterRequest, CancellationPolicy, InProcessRustAdapter, Materialization, NormalizedPath, ParserProfile, RootId, @@ -1962,7 +1962,7 @@ pub fn official_materializations( library_root: &std::path::Path, root_path: &NormalizedPath, root_bytes: &[u8], -) -> Result { +) -> Result { use polymodel_ldraw_core::CacheKey; use std::collections::{HashSet, VecDeque}; @@ -2333,7 +2333,7 @@ pub fn render_scene_window_configured( scene: &Scene, output: Option<&std::path::Path>, options: NativeRenderOptions, -) -> Result<(), String> { +) -> Result<(), RendererError> { render_scene_window_options_traced(scene, output, NativeTrace::default(), options) } @@ -3827,7 +3827,7 @@ pub type NativeSceneModel = Vec Result { +) -> Result { build_scene_model_for_view_with_resources(context, scene, None) } @@ -3835,8 +3835,8 @@ pub fn build_scene_model_for_view_with_resources( context: &three_d::Context, scene: &Scene, resources: Option<&[ModelResource]>, -) -> Result { - let plan = scene_render_plan(scene).map_err(|error| error.to_string())?; +) -> Result { + let plan = scene_render_plan(scene)?; build_scene_model_from_batches( context, scene, @@ -4569,7 +4569,7 @@ pub fn build_scene_model_parts_for_style( scene: &Scene, view: [f64; 3], style: RenderStyle, -) -> Result { +) -> Result { build_scene_model_parts_for_style_with_resources(context, scene, view, style, None) } @@ -4579,9 +4579,9 @@ pub fn build_scene_model_parts_for_style_with_resources( view: [f64; 3], style: RenderStyle, resources: Option<&[ModelResource]>, -) -> Result { +) -> Result { let started = Instant::now(); - let plan = scene_render_plan(scene).map_err(|error| error.to_string())?; + let plan = scene_render_plan(scene)?; let plan_elapsed = started.elapsed(); tracing::debug!( "[ldraw-preview] native-build-stage=plan elapsed_ms={} cumulative_ms={}", -- knotmirror 0.0.1