{"record":{"id":"1dadf0ab8daa24c9","repo":"GraphiteEditor/Graphite","slug":"failed-to-draw-arc","errorCode":null,"errorMessage":"Failed to draw arc","messagePattern":"Failed to draw arc","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"editor/src/messages/portfolio/document/overlays/utility_types_web.rs","lineNumber":839,"sourceCode":"\tpub fn dowel_pin(&mut self, position: DVec2, angle: f64, color: Option<&str>) {\n\t\tlet (x, y) = self.snap_to_physical_pixel_center(position).into();\n\t\tlet color = color.unwrap_or(COLOR_OVERLAY_YELLOW_DULL);\n\n\t\tself.start_dpi_aware_transform();\n\n\t\t// Draw the background circle with a white fill and blue outline\n\t\tself.render_context.begin_path();\n\t\tself.render_context.arc(x, y, DOWEL_PIN_RADIUS, 0., TAU).expect(\"Failed to draw the circle\");\n\t\tself.render_context.set_fill_style_str(COLOR_OVERLAY_WHITE);\n\t\tself.render_context.fill();\n\t\tself.render_context.set_stroke_style_str(color);\n\t\tself.render_context.stroke();\n\n\t\t// Draw the two blue filled sectors\n\t\tself.render_context.begin_path();\n\t\t// Top-left sector\n\t\tself.render_context.move_to(x, y);\n\t\tself.render_context.arc(x, y, DOWEL_PIN_RADIUS, FRAC_PI_2 + angle, PI + angle).expect(\"Failed to draw arc\");\n\t\tself.render_context.close_path();\n\t\t// Bottom-right sector\n\t\tself.render_context.move_to(x, y);\n\t\tself.render_context.arc(x, y, DOWEL_PIN_RADIUS, PI + FRAC_PI_2 + angle, TAU + angle).expect(\"Failed to draw arc\");\n\t\tself.render_context.close_path();\n\t\tself.render_context.set_fill_style_str(color);\n\t\tself.render_context.fill();\n\n\t\tself.end_dpi_aware_transform();\n\t}\n\n\tpub fn arc_sweep_angle(&mut self, offset_angle: f64, angle: f64, end_point_position: DVec2, bold_radius: f64, pivot: DVec2, text: &str, transform: DAffine2) {\n\t\tself.manipulator_handle(end_point_position, true, None);\n\t\tself.draw_arc_gizmo_angle(pivot, bold_radius, ARC_SWEEP_GIZMO_RADIUS, offset_angle, angle.to_radians());\n\t\tself.text(&text, COLOR_OVERLAY_BLUE, None, transform, 16., [Pivot::Middle, Pivot::Middle]);\n\t}\n\n\t/// Used by the Pen and Path tools to outline the path of the shape.","sourceCodeStart":821,"sourceCodeEnd":857,"githubUrl":"https://github.com/GraphiteEditor/Graphite/blob/c507b356453361e31638b8bff8f6d46b6da2961e/editor/src/messages/portfolio/document/overlays/utility_types_web.rs#L821-L857","documentation":"The dowel pin overlay draws two filled sectors with arc() calls whose start/end angles are FRAC_PI_2 + angle .. PI + angle. wasm-bindgen types arc as Result<(), JsValue>, and this .expect(\"Failed to draw arc\") turns any JS throw into a WASM abort. Spec-wise non-finite angles are ignored, not thrown, so the realistic throw is again a negative radius or a browser-specific error on an invalidated context.","triggerScenarios":"Calling dowel_pin with an angle or position that degenerates (NaN angle does not throw per spec but signals upstream math bugs), or arc throwing on a negative/invalid DOWEL_PIN_RADIUS or an invalidated 2D context.","commonSituations":"Passing an uninitialized (NaN) angle from transform decompositions into overlay drawing; refactoring DOWEL_PIN_RADIUS; browsers that throw rather than ignore degenerate arc arguments.","solutions":["Assert angle and position are finite (angle.is_finite()) before drawing the dowel pin sectors","Confirm DOWEL_PIN_RADIUS remains a positive constant after refactors","Handle the Result instead of expecting, logging and skipping the sector draw on error"],"exampleFix":"// before\nself.render_context.arc(x, y, DOWEL_PIN_RADIUS, FRAC_PI_2 + angle, PI + angle).expect(\"Failed to draw arc\");\n\n// after\nif let Err(e) = self.render_context.arc(x, y, DOWEL_PIN_RADIUS, FRAC_PI_2 + angle, PI + angle) {\n\tlog::error!(\"Failed to draw dowel pin sector: {e:?}\");\n}","handlingStrategy":"validation","validationCode":"if !angle.is_finite() {\n\tlog::error!(\"dowel_pin called with non-finite angle {angle}\");\n\treturn;\n}","typeGuard":null,"tryCatchPattern":"if let Err(js_err) = self.render_context.arc(x, y, DOWEL_PIN_RADIUS, FRAC_PI_2 + angle, PI + angle) {\n\tlog::error!(\"dowel pin sector arc failed: {js_err:?}\");\n}","preventionTips":["Check angle finiteness at overlay entry points (NaN rotations are the usual upstream bug)","Keep DOWEL_PIN_RADIUS a positive constant under test","Treat any arc Err as a symptom of context invalidation and re-check context health for the frame"],"tags":["rust","wasm-bindgen","canvas-2d","overlay-rendering","panic"],"backgroundTag":"canvas-2d-exception","analyzedSha":"c507b356453361e31638b8bff8f6d46b6da2961e","analyzedAt":"2026-08-16T21:57:18.596Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}