Can I catch exceptions in Custom Command?

william-j wrote on 5/24/2024, 2:26 PM

I am creating a new VEGAS Custom Command (or Extension). Is it able to catch the exceptions in the custom command?

If I throw an Exception in the custom command, or there are some null reference in the custom command, this will directly crash the whole VEGAS instead of show the error dialog like it in a VEGAS script. The users will find it hard to use if it crashed. However, it is impossible for me to handle all possible user errors at the first.

In VEGAS Script, we can put a try ... catch ... in the EntryPoint method, and wrap all the code inside. If caught any Exceptions, just call vegas.ShowError then close the script. So is anywhere to put try ... catch ... in a custom command?

If there is an exception, just show the exception to user or close the custom command window, do not crash the whole VEGAS.

Comments

jetdv wrote on 5/24/2024, 3:55 PM

Yes, you can use try/catch in custom commands as well.

william-j wrote on 5/25/2024, 6:16 AM

Yes, you can use try/catch in custom commands as well.

If so, where I can put the try/catch? I want to catch all the exceptions within the custom command, and won't let the VEGAS to crash. Should it be placed in CCTestCCM (ICustomCommandModule)?

jetdv wrote on 5/25/2024, 10:08 AM

I use the Try/Catch in individual routines where an issue might happen. I'm not sure you could use a "global" try/catch. For example, in Excalibur I have a Try/Catch in my PIP-MakeWall routine, Multi-Cam-SetRenderersAndTemplates, About-Open the manual PDF file, Assets-SetRenderersAndTemplates; Select files button, Audio-SetEffectPresets, Common-GetActiveMediaStream; MatchOutputAspect; DoRender, Config-GetValue; SetValue; SaveDoc; RemoveElement, Events-SetTransitionPresets, and a few other places.

Generally speaking, I'm using them when reading renderers, render templates, effects/transitions and their presets, doing a render, etc... So use them as needed. Don't try to use them as a global "catch all".