{"record":{"id":"cefda29b42b20620","repo":"elkowar/eww","slug":"couldn-t-parse-possible-values-are","errorCode":null,"errorMessage":"Couldn't parse {}: '{}'. Possible values are ...","messagePattern":"Couldn't parse (.+?): '(.+?)'\\. Possible values are \\.\\.\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/eww/src/util.rs","lineNumber":48,"sourceCode":"    }};\n}\n\n/// Parse a string with a concrete set of options into some data-structure,\n/// and return a nicely formatted error message on invalid values. I.e.:\n/// ```rs\n/// let input = \"up\";\n/// enum_parse { \"direction\", input,\n///   \"up\" => Direction::Up,\n///   \"down\" => Direction::Down,\n/// }\n/// ```\n#[macro_export]\nmacro_rules! enum_parse {\n    ($name:literal, $input:expr, $($($s:literal)|* => $val:expr),* $(,)?) => {\n        let input = $input.to_lowercase();\n        match input.as_str() {\n            $( $( $s )|* => Ok($val) ),*,\n            _ => Err(anyhow!(concat!(\"Couldn't parse \", $name, \": '{}'. Possible values are \", $($($s, \" \"),*),*), input))\n        }\n    };\n}\n\n/// Compute the difference of two lists, returning a tuple of\n/// (\n///   elements that where in a but not in b,\n///   elements that where in b but not in a\n/// ).\npub fn list_difference<'a, 'b, T: PartialEq>(a: &'a [T], b: &'b [T]) -> (Vec<&'a T>, Vec<&'b T>) {\n    let mut missing = Vec::new();\n    for elem in a {\n        if !b.contains(elem) {\n            missing.push(elem);\n        }\n    }\n\n    let mut new = Vec::new();","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/elkowar/eww/blob/48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa/crates/eww/src/util.rs#L30-L66","documentation":"The enum_parse! macro parses a user-supplied string into an enum by matching lowercased literal aliases. When no alias matches, it produces this error listing the name of the thing being parsed, the offending input, and all accepted values.","triggerScenarios":"Any call site of enum_parse! (e.g. parsing window position like anchor/position strings, geometry flags) receives a string that doesn't equal one of the defined literals (case-insensitive).","commonSituations":"Typo in a config value like position or anchor; using a synonym the macro doesn't know ('centred' vs 'center'); extra whitespace or punctuation in the value.","solutions":["Use one of the values listed in the error message exactly","Check for typos/aliases (e.g. 'center' vs 'centre')","Trim stray whitespace or quotes around the config value"],"exampleFix":"; before\n:geometry (geometry :anchor \"bottom centred\")\n\n; after\n:geometry (geometry :anchor \"bottom center\")","handlingStrategy":"validation","validationCode":"# check the value against accepted list before use\ncase \"$value\" in\n  l|r|t|b|tl|tr|bl|br|center) ;;\n  *) echo \"invalid value: $value\" >&2; exit 1;;\nesac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy accepted values verbatim from the error message","Trim whitespace/quotes from config values","Use lowercase values (macro lowercases input anyway)"],"tags":["eww","parsing","enum","macro"],"backgroundTag":"invalid-enum-value","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"}