// Rethrow.cpp : main project file.

#include "stdafx.h"

using namespace System;

void func(int a)
{
    try
    {
      if (a <= 0)
          throw gcnew System::ArgumentException(L"Aaaraaghhh! What wrong?");
    }
    catch(System::ArgumentException^ pex)
    {
        Console::WriteLine(L"Exception caught in func()");
        throw;   // rethrow the exception
    }
}

int main(array<System::String ^> ^args)
{
	Console::WriteLine(L"Throw Test");
	try
	{
		int n = 3;
		Console::WriteLine(L"Calling with n = 3");
		func(n);
		Console::WriteLine(L"Calling with n = 0");
		n = 0;
		func(n);
	}
	catch(System::ArgumentException^ pex)
	{
		Console::WriteLine(L"Exception was {0}", pex);
	}
	finally
	{
		Console::WriteLine(L"This is the finally block");
	}
	Console::WriteLine(L"All done");

	return 0;
}
