Pay attention: integer overflow exceptions will not be even thrown be default. To throw them you will need to do the calculation in checked mode, under
checked
statement. It will throw exception in both cases: wrapping over the
MaxValue
(0 for unsigned types) boundary down and over the
MaxValue
boundary up. The type
tinyint
is unsigned, 0 to 0xFF, which is represented by the type
byte
in .NET. So, for example:
checked {
byte b = 200;
b += 60;
b = 0;
b--;
}
In SQL Server, arithmetic overflow will always happen in case of overflow during calculations or converting. See:
http://msdn.microsoft.com/en-us/library/ms163363.aspx[
^],
http://msdn.microsoft.com/en-us/library/ms191530.aspx[
^],
http://support.microsoft.com/kb/961695[
^].
To catch all exceptions, you need to catch them on top of the stack of each thread. UI needs special treatment to catch all exceptions inside main event loop of the application. Both WPF and
System.Windows.Forms
provide such a mode of handling uncaught UI thread exceptions and event used to handle it withing the loop. See:
http://msdn.microsoft.com/en-us/library/ms157905.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.onthreadexception.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.application.dispatcherunhandledexception.aspx[
^].
—SA