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

fix stylecop issue and add message to exception #2750

Merged
merged 1 commit into from
Oct 16, 2019

Conversation

johnataylor
Copy link
Member

@EricDahlvang stylecop was complaining about the exception class - while i was in there I added the message as we discussed and also made the SafeCast throw this exception.

arguable a null Action or BotMessagePreviewAction should be a bad request? currently it would be a NotImplemented i'm tempted to just leave this at this point...

@fuselabs
Copy link
Collaborator

✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.dll compared against version 4.5.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.AI.Luis.dll compared against version 4.5.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.AI.QnA.dll compared against version 4.5.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.ApplicationInsights.dll compared against version 4.5.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Azure.dll compared against version 4.5.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Dialogs.dll compared against version 4.5.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.TemplateManager.dll compared against version 4.5.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Configuration.dll compared against version 4.5.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Connector.dll compared against version 4.5.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Schema.dll compared against version 4.5.3

Copy link
Member

@EricDahlvang EricDahlvang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error msg in the body is a great addition!

@EricDahlvang EricDahlvang added 4.6 October 31, 2019 Release teams labels Oct 16, 2019
Copy link
Member

@stevengum stevengum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arguable a null Action or BotMessagePreviewAction should be a bad request? currently it would be a NotImplemented i'm tempted to just leave this at this point...

I'm not sure I follow this (or I'm probably just missing something)...

We already throw a BadRequest if the original OnFileConsentAsync() gets to a point where it would Action might be null. Isn't this covered in the switch?

If there is no TurnContext.Activity.Value period, we definitely know the whole request is incorrect and throw an exception in the SafeCast().

All of that said, LGTM.

@@ -315,24 +315,26 @@ private static T SafeCast<T>(object value)
var obj = value as JObject;
if (obj == null)
{
throw new Exception($"expected type '{value.GetType().Name}'");
throw new InvokeResponseException(HttpStatusCode.BadRequest, $"expected type '{value.GetType().Name}'");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can check the TurnContext.Activity.Value with a truthy check, if it's null I'll throw a BadRequest... There's nothing else to be done on the type casting in JS.

Copy link
Contributor

@tomlm tomlm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@tomlm tomlm merged commit 378043d into master Oct 16, 2019
@tomlm tomlm deleted the johtaylo/style-and-exceptions branch October 16, 2019 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.6 October 31, 2019 Release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants