clsVersionControl: Error trapping setting. (We need this to "Break in Class Modules" for this add-in) #501
-
Hi! Why is "Break in Class Modules" needed? That's the option I never need ;) Background: I tried "Break On Unhandled Errors" (2) and did not notice any difference. Kind regards, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Great question! I personally use it for many of the same reasons described here. Because class modules are extensively used in this project, it makes it easier to actually break on the code line that is triggering the error (which is often within a class module), rather than simply highlighting the calling code in the last standard module and requiring me to step through the code line by line to find the actual breaking point within the class. For your unit testing framework, you might consider setting the VBA option yourself before executing the test suite, just to ensure consistent behavior, regardless of which setting the user is currently using. You can see how I do this in the add-in here: |
Beta Was this translation helpful? Give feedback.
-
Hi! The behavior only occurs when I want to test the VCS add-in (clsVersionControlRunBeforeExportTests). |
Beta Was this translation helpful? Give feedback.
Some of that probably comes down to the personal preferences and debugging approach of each developer. 😄 If the testing framework is expecting or needing a specific level for the desired functionality, I would suggest caching the current value, setting the needed value (in this case 2), then restoring the user's preference. That way the test can run consistently, regardless of what value the developer was using.
Just a tip on implementing this, I have found that it is usually much more performant to read the current value and only change if needed, rather than always setting the value. (Reads on property access tend to be much faster than writes.) Of course there is a balance between perf…