It depends on the language that you're using, but the convention is that the try block contains statements that can throw exceptions, and thrown exceptions are caught by the catch() blocks following the try. You need to explicitly throw an exception before it can be caught.
It looks like you're using C#. Consider reading https://msdn.microsoft.com/en-us/library/0yd65esw.aspx for more information about try-catch statements in C#.
Using exceptions in your case may not be necessary. Consider using an if statement, like this:
decimal result = a + b;
if ((result > MAX_VALUE) || (result < MIN_VALUE))
{
// Do stuff.
}
But to answer your question more directly, here's how you would do it using exceptions:
decimal result = a + b;
try
{
if ((result > MAX_VALUE) || (result < MIN_VALUE))
{
throw new System.ArithmeticException(); // Or make an exception type.
}
}
catch (System.ArithmeticException e)
{
// Do stuff.
}
Or perhaps you would throw the exception in Add, but not catch it. Then it would be the caller's responsibility to handle the exception, or let the program crash. That would look like this:
// Adds two numbers. Throws a System.ArithmeticException if the result
// is greater than MAX_VALUE or less than MIN_VALUE.
public static decimal Add(decimal a, decimal b)
{
decimal result = a + b;
if ((result > MAX_VALUE) || (result < MIN_VALUE))
{
throw new System.ArithmeticException(); // Or make an exception type.
}
}
And callers would need to wrap calls to Add in a try {} catch if they expect some results to be bigger than MAX_VALUE or less than MIN_VALUE (or, callers could not catch the exception and the program would crash).