{"record":{"id":"6a6aec151f67281d","repo":"elkowar/eww","slug":"css-error","errorCode":null,"errorMessage":"CSS error: {}","messagePattern":"CSS error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/eww/src/app.rs","lineNumber":604,"sourceCode":"        Ok(())\n    }\n\n    /// Load a given CSS string into the gtk css provider, returning a nicely formatted [`DiagError`] when GTK errors out\n    pub fn load_css(&mut self, file_id: usize, css: &str) -> Result<()> {\n        if let Err(err) = self.css_provider.load_from_data(css.as_bytes()) {\n            static PATTERN: Lazy<regex::Regex> = Lazy::new(|| regex::Regex::new(r\"[^:]*:(\\d+):(\\d+)(.*)$\").unwrap());\n            let nice_error_option: Option<_> = (|| {\n                let captures = PATTERN.captures(err.message())?;\n                let line = captures.get(1).unwrap().as_str().parse::<usize>().ok()?;\n                let msg = captures.get(3).unwrap().as_str();\n                let db = error_handling_ctx::FILE_DATABASE.read().ok()?;\n                let line_range = db.line_range(file_id, line - 1).ok()?;\n                let span = Span(line_range.start, line_range.end - 1, file_id);\n                Some(DiagError(gen_diagnostic!(msg, span)))\n            })();\n            match nice_error_option {\n                Some(error) => Err(anyhow!(error)),\n                None => Err(anyhow!(\"CSS error: {}\", err.message())),\n            }\n        } else {\n            Ok(())\n        }\n    }\n}\n\nfn initialize_window<B: DisplayBackend>(\n    window_init: &WindowInitiator,\n    monitor: Monitor,\n    root_widget: gtk::Widget,\n    window_scope: ScopeIndex,\n) -> Result<EwwWindow> {\n    let monitor_geometry = monitor.geometry();\n    let (actual_window_rect, x, y) = match window_init.geometry {\n        Some(geometry) => {\n            let rect = get_window_rectangle(geometry, monitor_geometry);\n            (Some(rect), rect.x(), rect.y())","sourceCodeStart":586,"sourceCodeEnd":622,"githubUrl":"https://github.com/elkowar/eww/blob/48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa/crates/eww/src/app.rs#L586-L622","documentation":"load_css compiles the user's stylesheet (CSS/SCSS) and surfaces any compile error from the grass parser. When the error carries span/line information, eww renders a rich diagnostic; otherwise it falls back to this plain 'CSS error: {}' wrapping the parser's message.","triggerScenarios":"Calling load_css (during server initialization or a `reload` command) with a stylesheet that fails grass's compilation: bad selectors, unbalanced braces, invalid property values, or unparseable SCSS syntax.","commonSituations":"Hand-edited eww.scss/eww.css with a syntax mistake; SCSS features unsupported by the grass crate; stray characters pasted into the stylesheet; a failed reload after a config edit.","solutions":["Read the parser message after 'CSS error:' to locate the bad rule and fix the syntax","If a diagnostic with a line number was printed instead, go to that line in the stylesheet","Validate the file with a SCSS/CSS linter or a standalone grass/sass compile before reloading"],"exampleFix":"/* before */\n.foo { color: ; }\n\n/* after */\n.foo { color: #ff0000; }","handlingStrategy":"validation","validationCode":"// pre-validate stylesheet with grass/sass before reload\nnpx sass --no-source-map ~/.config/eww/eww.scss > /dev/null && echo OK","typeGuard":null,"tryCatchPattern":"// rust: surface diagnostics with context\nif let Err(err) = app.load_css(path) {\n    eprintln!(\"failed to load stylesheet: {err:#}\");\n}","preventionTips":["Lint CSS/SCSS before committing config changes","Keep stylesheet edits small and reload incrementally","Stick to SCSS features grass supports"],"tags":["eww","css","scss","parsing"],"backgroundTag":"schema-validation-failed","analyzedSha":"48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa","analyzedAt":"2026-09-08T03:13:26.897Z","contentChangedAt":"2026-09-08T03:13:26.897Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}