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(Archicad): CNX-8392 Handle CA1031 warnings in ArchiCAD projects #3122

Merged
merged 3 commits into from
Jan 9, 2024

Conversation

jozseflkiss
Copy link
Contributor

@jozseflkiss jozseflkiss commented Jan 8, 2024

Description & motivation

Handle CA1031 warnings in ArchiCAD projects
https://spockle.atlassian.net/browse/CNX-8392

Changes:

Specific exceptions used.

Checklist:

  • My pull request follows the guidelines in the Contributing guide?
  • My pull request does not duplicate any other open Pull Requests for the same update/change?
  • My commits are related to the pull request and do not amend unrelated code or documentation.
  • My code follows a similar style to existing code.
  • I have added appropriate tests.
  • I have updated or added relevant documentation.

@jozseflkiss jozseflkiss changed the base branch from main to dev January 8, 2024 12:31
@jozseflkiss jozseflkiss changed the title Archicad/ca1031 fix(Archicad): CNX-8392 Handle CA1031 warnings in ArchiCAD projects Jan 8, 2024
@jozseflkiss jozseflkiss removed the request for review from teocomi January 8, 2024 12:33
Copy link
Contributor

@AlanRynne AlanRynne left a comment

Choose a reason for hiding this comment

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

Just some minor changes around logging

Comment on lines 30 to 38
catch (ArgumentNullException)
{
return null;
}
catch (TaskCanceledException)
{
return null;
}
catch (ObjectDisposedException)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming Execute cannot throw within? If so, would we want to add logging to some these since we're swallowing them?

@@ -27,7 +27,15 @@ internal class AsyncCommandProcessor
{
return Task.Run(command.Execute, token);
}
catch (Exception e)
catch (ArgumentNullException)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this one is only going to throw if command.Execute is null, which can't be the case since it's part of the ICommand interface.

I think we don't really need to catch this as it would really be an unexpected event (provided input was invalid somehow)

{
throw;
SpeckleLog.Logger.Warning("Failed to convert element type {elementType}", elementType.ToString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Warnings should also include their exception if it exists as first argument.

}
catch (Exception)
catch (ObjectDisposedException)
{
SpeckleLog.Logger.Warning("Failed to convert element type {elementType}", elementType.ToString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, including the exception makes the warning more useful in our logs.

Copy link
Contributor

@AlanRynne AlanRynne left a comment

Choose a reason for hiding this comment

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

Changes from my comments look good. In we go 🚀

return null;
}
catch (ObjectDisposedException)
catch (Exception ex) when (ex is TaskCanceledException or ObjectDisposedException)
Copy link
Contributor

Choose a reason for hiding this comment

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

Legit ♥️

@AlanRynne AlanRynne merged commit be532b3 into dev Jan 9, 2024
1 check passed
@AlanRynne AlanRynne deleted the archicad/CA1031 branch January 9, 2024 09:08
@JR-Morgan JR-Morgan added this to the 2.18 milestone Jan 10, 2024
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.

3 participants