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:(tekla): CNX-8391 Handle warnings CA1031 #3118

Merged
merged 12 commits into from
Jan 8, 2024

Conversation

jsdbroughton
Copy link
Contributor

@jsdbroughton jsdbroughton commented Dec 20, 2023

THIS PR SHOULD BE MERGED AFTER ExceptionHelpers has merged.

Changes to:

Connector

MainForm
StreamStateManager

Converter

ConverterTeklaStructureUtils
ConvertMeshToNative

In general I think from my non-codebase owner eye, there are many areas where more exceptions may be raised and are not handled. This PR addresses the generic cases where they were.

continues on the specific error previously commented that should be swallowed, but throws on all other insertion errors.
…ures

The code changes add logging functionality to handle exceptions thrown by the DynamicBase class when setting properties that cannot be set. The exceptions are not fatal and should simply be logged. The commit also includes a warning message with details about the element, property, and reason for skipping.
This commit adds the following changes to the MainForm class:
- Added an InitializeComponents method to initialize the components of the MainForm.
- Added a SetupApplication method to set up the application, including event subscriptions, UI build, and model bindings.
- Added a SubscribeToEvents method to subscribe to necessary application events.
- Added a BuildAndShowMainWindow method to build and display the main window of the application.
- Added a SetTeklaAsOwner method to set the Tekla application as the owner of the main window.

These changes improve the initialization and setup process in MainForm, ensuring that necessary components are properly initialized and that event subscriptions, UI build, and model bindings are correctly set up.
This commit adds logging and error handling to the StreamStateManager class. It introduces the use of Speckle.Core.Logging for logging errors. Significant changes include:
- Added a using statement for the System namespace
- Added a using statement for the Speckle.Core.Logging namespace
- Implemented error handling in ReadState method, catching JsonException and returning an empty list if deserialization fails
- Implemented error handling in WriteState method, catching exceptions and logging an error message if writing to file fails
- Implemented error handling in ClearStreamStateList method, catching exceptions and logging an error message if clearing the stream state file fails
- Updated comments with more detailed explanations of methods and their behavior
Copy link
Contributor

@BovineOx BovineOx left a comment

Choose a reason for hiding this comment

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

A few things to consider, few questions

- Renamed private field `_speckleFilePath` to `s_speckleFilePath`
- Added logging warning when deserialization of saved stream state list fails
- Updated method `WriteStreamStateList` to handle empty or null stream state string
- Updated method `ClearStreamStateList` to handle null or non-existent speckle file path
- Updated method `GetOrCreateSpeckleFilePath` to use lowercase variable names and added error handling for file creation/retrieval
- Updated method `ReadSpeckleFile` to use lowercase variable name and added error handling for file reading
@BovineOx
Copy link
Contributor

BovineOx commented Jan 4, 2024

Just a few things to consider, but minor, once you've done so happy for you to resolve the comments - ping me if it needs an approval still

jsdbroughton and others added 5 commits January 4, 2024 14:55
Previously, there was a TODO comment suggesting to consider what to do in the case where the insert operation returned false but didn't throw an exception and no matching shape was found. This commit changes that behavior by throwing a `ConversionException` with an appropriate error message instead.
The code changes fix an issue where the file stream was not being properly checked for write access before attempting to write to it. This could result in an error when trying to write the stream state list to the file. The changes include adding a check for write access and throwing a `SpeckleException` with an appropriate error message if writing fails.
The commit fixes the exception handling in the SetupApplication method. Instead of catching all exceptions and logging them, it now catches only general exceptions. The error message is also updated to include the specific error message from the caught exception.
Copy link
Member

@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.

Approving since all conversations are resolved and CI is ✅

@AlanRynne AlanRynne merged commit 08789b8 into dev Jan 8, 2024
30 checks passed
@AlanRynne AlanRynne deleted the CNX-8391-Handle-CA1031-warnings-in-Tekla-projects branch January 8, 2024 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants