d2phap/ImageGlass Β· error Β· ArgumentException
'{orderTypeStr}' is not a valid loading order. ---------- οΏ½
Error message
'{orderTypeStr}' is not a valid loading order.
----------
ππΌ Method: IG_SetLoadingOrderType What it means
Thrown by the string overload of IG_SetLoadingOrderType when Enum.TryParse<ImageOrderType>(orderTypeStr) fails. ImageOrderType has only two members, case-insensitively parsed: Asc and Desc. Any other string raises ArgumentException.
Source
Thrown at source/ImageGlass.Lib/Common/ServiceProviders/AppAPIs/AppAPIProvider.cs:1563
/// Sets the image loading order value.
/// </summary>
public static void IG_SetLoadingOrderBy(ImageOrderBy orderBy)
{
if (orderBy == Core.Config.ImageLoadingOrder) return;
Core.Config.ImageLoadingOrder = orderBy;
IG_ReloadList();
}
/// <summary>
/// Sets the image loading order value.
/// </summary>
public void IG_SetLoadingOrderType(string? orderTypeStr)
{
if (!Enum.TryParse<ImageOrderType>(orderTypeStr, out var orderType))
{
throw new ArgumentException($"""
'{orderTypeStr}' is not a valid loading order.
----------
ππΌ Method: {nameof(IG_SetLoadingOrderType)}
""",
nameof(orderTypeStr));
}
IG_SetLoadingOrderType(orderType);
}
/// <summary>
/// Sets the image loading order value.
/// </summary>
public static void IG_SetLoadingOrderType(ImageOrderType orderType)
{
if (orderType == Core.Config.ImageLoadingOrderType) return;View on GitHub (pinned to 4a3c4fecef)
Solutions
- Use exactly 'Asc' or 'Desc' (case-insensitive).
- Validate with Enum.TryParse<ImageOrderType> upstream and call the typed overload.
- Map common aliases ('ascending' -> Asc, 'descending' -> Desc) before calling.
Example fix
// before
api.IG_SetLoadingOrderType(userInput);
// after
if (Enum.TryParse<ImageOrderType>(userInput?.Trim(), true, out var orderType))
{
api.IG_SetLoadingOrderType(orderType);
} Defensive patterns
Strategy: validation
Validate before calling
if (!Enum.TryParse<ImageOrderType>(orderTypeStr?.Trim(), true, out var orderType))
throw new ArgumentException($"Unknown order type '{orderTypeStr}'.");
api.IG_SetLoadingOrderType(orderType); Type guard
static bool IsValidOrderType(string? s) => Enum.TryParse<ImageOrderType>(s?.Trim(), true, out _);
Try / catch
try { api.IG_SetLoadingOrderType(orderTypeStr); }
catch (ArgumentException ex) when (ex.ParamName == nameof(orderTypeStr))
{ /* valid: Asc, Desc */ } Prevention
- Use exactly 'Asc' or 'Desc'.
- Map 'ascending'/'descending' upstream.
- Validate with Enum.TryParse<ImageOrderType> before calling.
When it happens
Trigger: Calling IG_SetLoadingOrderType(string) with 'ascending'/'descending', 'a'/'d', '1'/'0' as a non-numeric label, 'up'/'down', or any value other than Asc/Desc.
Common situations: Config authored with a long form ('ascending'); user types a short alias; legacy v9 name; trailing whitespace.
Related errors
- '{orderByStr}' is not a valid loading order. ---------- ποΏ½
- '{modeStr}' is not a valid zoom mode. ---------- ππΌ Metho
- '{channelsStr}' is not a valid color channel. ---------- π
- '{optionStr}' is not a valid rotation option. ---------- π
- '{optionStr}' is not a valid flip option. ---------- ππΌ M
AI-assisted analysis of d2phap/ImageGlass@4a3c4fecef (2026-08-13).
Data as JSON: /api/errors/c091ab089ddfdd32.
Report an issue: GitHub.