Skip to content

fix: Include the offending expression in expr2Uci's error message#293

Open
dimension-zero wants to merge 1 commit into
fsprojects:masterfrom
dimension-zero:pr/09-expr2uci-error
Open

fix: Include the offending expression in expr2Uci's error message#293
dimension-zero wants to merge 1 commit into
fsprojects:masterfrom
dimension-zero:pr/09-expr2uci-error

Conversation

@dimension-zero
Copy link
Copy Markdown
Contributor

Summary

Utils.expr2Uci raises invalidArg "expr" "Only union constructors are permitted in expression based queries." without naming the expression. Thread the original expression through sprintf "%A", cap at 200 chars, and include it in the message.

Why

Callers using the quoted-DU API (GetSubCommandParser, GetResult, etc.) can hit this if they pass anything more complex than a bare constructor. Without the expression in the message they have to bisect their call sites to find the offender.

Test plan

  • dotnet build -c Release — clean
  • dotnet test -c Release — 112/112 pass

`expr2Uci` raises `invalidArg "expr" "Only union constructors are permitted
in expression based queries."` without saying which expression failed. When
a caller passes a more complex lambda (e.g. `<@ fun x -> Foo (x + 1) @>`),
the user has no signal from the error which call site is the problem.

Render the expression via `%A`, cap at 200 chars (long pretty-printed
quotations can be unwieldy), and include it in the message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant