MCPcopy Create free account
hub / github.com/csskit/csskit / build_error

Function build_error

crates/csskit_wasm/src/lib.rs:145–161  ·  view source on GitHub ↗
(err: &Diagnostic, source: &str, w: &mut impl Write)

Source from the content-addressed store, hash-verified

143}
144
145fn build_error(err: &Diagnostic, source: &str, w: &mut impl Write) {
146 #[cfg(feature = "miette")]
147 {
148 #[cfg(feature = "fancy")]
149 let handler = GraphicalReportHandler::new_themed(GraphicalTheme::unicode_nocolor());
150 #[cfg(not(feature = "fancy"))]
151 let handler = JSONReportHandler::new();
152
153 let miette_err = err.into_diagnostic(source);
154 let err_with_source = miette::Report::new(miette_err);
155 if handler.render_report(w, &*err_with_source).is_ok() {
156 return;
157 }
158 }
159 let DiagnosticMeta { code, message, help, .. } = (err.formatter)(err, source);
160 write!(w, "Error [{code}]: {message}\nHelp: {help}\n").unwrap();
161}
162
163#[wasm_bindgen]
164#[derive(Debug)]

Callers 1

parse_error_reportFunction · 0.85

Calls 1

into_diagnosticMethod · 0.80

Tested by

no test coverage detected