When an exception occurs in a try block, the system searches the associated catch blocks in the order they appear in application code, until it locates a catch block that handles the exception. A catch block handles an exception of type T if the type filter of the catch block specifies T or any type that T derives from. The system stops searching after it finds the first catch block that handles the exception. For this reason, in application code, a catch block that handles a type must be specified before a catch block that handles its base types, as demonstrated in the example that follows this section. A catch block that handles System.Exception is specified last.
Hi,Thanks Gile. I figured it was a matter of it being confused as to which exception was being called if that's the right terminology.
Autodesk.AutoCAD.Runtime.Exception (as all .NET exception types) derives from System.Exception.
So, using System.Exception will catch both specific AutoCAD exceptions and non-specific ones.
But a better practice is to use several catch blocks so that you can notify the end user (or developper) which kind of exception was thrown (see this topic (https://msdn.microsoft.com/en-us/library/0yd65esw.aspx)).Code - C#: [Select]
// AutoCAD specific: catch (Autodesk.AutoCAD.Runtime.Exception e) { ed.WriteMessage("\nAutoCAD error: " + e.Message); } // Non-specific: catch (SystemException e) { ed.WriteMessage("\nSystem error: " + e.Message); }