mgth/LittleBigMouse · error · FormatException

Enter at least one KEY_ command.

Error message

Enter at least one KEY_ command.

What it means

Thrown at the end of RemoteMacro.Parse when the resulting macro is empty: either the sequence string was null/whitespace or it contained only separator characters and numeric delay tokens, so no actual KEY_ command was collected. It guards callers against sending a do-nothing macro to the remote-control channel.

Solutions

  1. Provide a macro sequence containing at least one KEY_ command, e.g. 'KEY_POWER'.
  2. Remove separator-only content (commas, semicolons, plus signs, newlines) that yields no tokens.
  3. Do not enter delays alone; a numeric token only modifies the preceding KEY_ command.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/RemoteMacro.cs:32 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mgth/LittleBigMouse@7a42f01d47 (2026-09-16). Data as JSON: /api/errors/03841edb99aedb4d. Report an issue: GitHub.

Appendix: source

Thrown at LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/RemoteMacro.cs:32

        foreach (var token in tokens)
        {
            if (int.TryParse(token, out var milliseconds))
            {
                if (result.Count == 0) throw new FormatException("A delay must follow a KEY_ command.");
                if (milliseconds is < 0 or > 10000)
                    throw new FormatException("Macro delays must be between 0 and 10000 ms.");
                result[^1] = (result[^1].Key, TimeSpan.FromMilliseconds(milliseconds));
                continue;
            }

            var key = token.ToUpperInvariant();
            if (!key.StartsWith("KEY_", StringComparison.Ordinal) || key.Any(char.IsWhiteSpace))
                throw new FormatException($"Invalid remote key: {token}");
            result.Add((key, TimeSpan.FromMilliseconds(150)));
        }

        if (result.Count == 0) throw new FormatException("Enter at least one KEY_ command.");
        return result;
    }
}

View on GitHub (pinned to 7a42f01d47)