elkowar/eww · error

Couldn't parse : ' '. Possible values are ...

Error message

Couldn't parse {}: '{}'. Possible values are ...

What it means

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.

Solutions

  1. Use one of the values listed in the error message exactly
  2. Check for typos/aliases (e.g. 'center' vs 'centre')
  3. Trim stray whitespace or quotes around the config value

Example fix

; before
:geometry (geometry :anchor "bottom centred")

; after
:geometry (geometry :anchor "bottom center")
Defensive patterns

Strategy: validation

Validate before calling

# check the value against accepted list before use
case "$value" in
  l|r|t|b|tl|tr|bl|br|center) ;;
  *) echo "invalid value: $value" >&2; exit 1;;
esac

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of elkowar/eww@48f5aa8b37 (2026-09-08). Data as JSON: /api/errors/cefda29b42b20620. Report an issue: GitHub.

Appendix: source

Thrown at crates/eww/src/util.rs:48

    }};
}

/// Parse a string with a concrete set of options into some data-structure,
/// and return a nicely formatted error message on invalid values. I.e.:
/// ```rs
/// let input = "up";
/// enum_parse { "direction", input,
///   "up" => Direction::Up,
///   "down" => Direction::Down,
/// }
/// ```
#[macro_export]
macro_rules! enum_parse {
    ($name:literal, $input:expr, $($($s:literal)|* => $val:expr),* $(,)?) => {
        let input = $input.to_lowercase();
        match input.as_str() {
            $( $( $s )|* => Ok($val) ),*,
            _ => Err(anyhow!(concat!("Couldn't parse ", $name, ": '{}'. Possible values are ", $($($s, " "),*),*), input))
        }
    };
}

/// Compute the difference of two lists, returning a tuple of
/// (
///   elements that where in a but not in b,
///   elements that where in b but not in a
/// ).
pub fn list_difference<'a, 'b, T: PartialEq>(a: &'a [T], b: &'b [T]) -> (Vec<&'a T>, Vec<&'b T>) {
    let mut missing = Vec::new();
    for elem in a {
        if !b.contains(elem) {
            missing.push(elem);
        }
    }

    let mut new = Vec::new();

View on GitHub (pinned to 48f5aa8b37)