Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GetValue to throw on error - HOLD #6604

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,17 @@ public virtual Expression ToExpression()
/// </summary>
/// <param name="data">data to use for expression binding.</param>
/// <returns>Value or default(T) if not found.</returns>
/// <remarks>An error will be thrown if data is an invalid expression.</remarks>
public virtual T GetValue(object data)
{
return this.TryGetValue(data).Value;
var (value, error) = TryGetValue(data);

if (error != null)
{
throw new ArgumentException(error);
}

return value;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ protected async override Task<InputState> OnRecognizeInputAsync(DialogContext dc
{
// First check whether the prompt was sent to the user with numbers - if it was we should recognize numbers
var defaults = DefaultChoiceOptions[culture];
var choiceOptions = ChoiceOptions?.GetValue(dc.State) ?? defaults.Item3;
var opts = await GetChoiceOptionsAsync(dc, defaults).ConfigureAwait(false);
var choiceOptions = opts ?? defaults.Item3;

// This logic reflects the fact that IncludeNumbers is nullable and True is the default set in Inline style
if (!choiceOptions.IncludeNumbers.HasValue || choiceOptions.IncludeNumbers.Value)
Expand Down
Loading