Intellisense Code snippet auto insert exception try block?

In the code editor, when I hover over a class e.g. Thread.Start there is a description of the class. This also lists all the exceptions for that class.

Does anyone have a code snippet that can insert a try catch final block based on the exceptions listed

Something like this

try
{
Thread.Start();
}
catch (ThreadStateException)
{
Console.Write("ThreadStateException");
}
catch (InvalidOperationException)
{
Console.Write("InvalidOperationException");
}
catch (SecurityException)
{
Console.Write("SecurityException");
}
catch (OutOfMemoryException)
{
Console.Write("OutOfMemoryException");
}
finally ()
{
}

I am not use if this is even possible or perhaps it is out of the range of snippet capability.

I would be keen to get peoples feedback on this.



Answer this question

Intellisense Code snippet auto insert exception try block?

  • MichaelHale

    The dxcore from developers express is free toolkit which makes it easy to write visual studio addins. There is the vb exception helper project on the gotdotnet website which will allow you to add all the exception handlers for a method.

    The dxcore does not work with vb express.


  • mc77

    It is out of the range of the snippet editor.


  • Intellisense Code snippet auto insert exception try block?