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

[#4022] Throwing Generic Exceptions - Dialogs Adaptive Inputs #4953

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static ImportResolverDelegate ResourceExplorerResolver(string locale, Dic
var resource = resources.FirstOrDefault(u => LGResourceLoader.ParseLGFileName(u.Id).prefix.ToLowerInvariant() == LGResourceLoader.ParseLGFileName(resourceName).prefix.ToLowerInvariant());
if (resource == null)
{
throw new Exception($"There is no matching LG resource for {resourceName}");
throw new InvalidOperationException($"There is no matching LG resource for {resourceName}");
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override async Task<object> GenerateAsync(DialogContext dialogContext, st

if (fallbackLocales.Count == 0)
{
throw new Exception($"No supported language found for {targetLocale}");
throw new InvalidOperationException($"No supported language found for {targetLocale}");
}

var generators = new List<LanguageGenerator>();
Expand All @@ -91,7 +91,7 @@ public override async Task<object> GenerateAsync(DialogContext dialogContext, st

if (generators.Count == 0)
{
throw new Exception($"No generator found for language {targetLocale}");
throw new InvalidOperationException($"No generator found for language {targetLocale}");
}

var errors = new List<string>();
Expand All @@ -109,7 +109,7 @@ public override async Task<object> GenerateAsync(DialogContext dialogContext, st
}
}

throw new Exception(string.Join(",\n", errors.Distinct()));
throw new InvalidOperationException(string.Join(",\n", errors.Distinct()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public override Task<object> GenerateAsync(DialogContext dialogContext, string t
{
if (!string.IsNullOrEmpty(this.Id))
{
throw new Exception($"{Id}:{err.Message}");
throw new InvalidOperationException($"{Id}:{err.Message}");
}

throw;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected override object OnInitializeOptions(DialogContext dc, object options)
var (choices, error) = this.Choices.TryGetValue(dc.State);
if (error != null)
{
throw new Exception(error);
throw new InvalidOperationException(error);
}

op.Choices = choices;
Expand Down Expand Up @@ -224,7 +224,7 @@ protected override async Task<IActivity> OnRenderPromptAsync(DialogContext dc, I
var (choices, error) = this.Choices.TryGetValue(dc.State);
if (error != null)
{
throw new Exception(error);
throw new InvalidOperationException(error);
}

return this.AppendChoices(prompt.AsMessageActivity(), channelId, choices, this.Style.GetValue(dc.State), choiceOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected override Task<InputState> OnRecognizeInputAsync(DialogContext dc, Canc
}
else
{
throw new Exception($"OutputFormat Expression evaluation resulted in an error. Expression: {OutputFormat.ToString()}. Error: {error}");
throw new InvalidOperationException($"OutputFormat Expression evaluation resulted in an error. Expression: {OutputFormat.ToString()}. Error: {error}");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected override Task<InputState> OnRecognizeInputAsync(DialogContext dc, Canc
}
else
{
throw new Exception($"OutputFormat Expression evaluation resulted in an error. Expression: {this.OutputFormat}. Error: {error}");
throw new InvalidOperationException($"OutputFormat Expression evaluation resulted in an error. Expression: {this.OutputFormat}. Error: {error}");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ private async Task<InputState> RecognizeInputAsync(DialogContext dc, int turnCou
var (value, valueError) = this.Value.TryGetValue(dc.State);
if (valueError != null)
{
throw new Exception($"In InputDialog, this.Value expression evaluation resulted in an error. Expression: {this.Value}. Error: {valueError}");
throw new InvalidOperationException($"In InputDialog, this.Value expression evaluation resulted in an error. Expression: {this.Value}. Error: {valueError}");
}

input = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected override Task<InputState> OnRecognizeInputAsync(DialogContext dc, Canc
}
else
{
throw new Exception($"In TextInput, OutputFormat Expression evaluation resulted in an error. Expression: {this.OutputFormat}. Error: {error}");
throw new InvalidOperationException($"In TextInput, OutputFormat Expression evaluation resulted in an error. Expression: {this.OutputFormat}. Error: {error}");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected override Task<InputState> OnRecognizeInputAsync(DialogContext dc, Canc
}
else
{
throw new Exception($"In TextInput, OutputFormat Expression evaluation resulted in an error. Expression: {OutputFormat.ToString()}. Error: {error}");
throw new InvalidOperationException($"In TextInput, OutputFormat Expression evaluation resulted in an error. Expression: {OutputFormat.ToString()}. Error: {error}");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static string FallbackLocale(string locale, IList<string> optionalLocales
return string.Empty;
}

throw new Exception($"there is no locale fallback for {locale}");
throw new InvalidOperationException($"there is no locale fallback for {locale}");
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void AddExternalCondition(string condition)
}
catch (Exception e)
{
throw new Exception($"Invalid constraint expression: {this.Condition}, {e.Message}");
throw new InvalidOperationException($"Invalid constraint expression: {this.Condition}, {e.Message}");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public async Task TestMultiLangImport()
Assert.Equal("from c.en.lg", result);

// there is no 'greeting' template in b.en-us.lg, no more fallback to b.lg
var ex = await Assert.ThrowsAsync<Exception>(async () => await generator.GenerateAsync(GetDialogContext(), "${greeting()}", null));
var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await generator.GenerateAsync(GetDialogContext(), "${greeting()}", null));
Assert.Contains("greeting does not have an evaluator", ex.Message);

resource = resourceExplorer.GetResource("a.lg") as FileResource;
Expand Down