I have a nested try-catch code like below:
void A()
{
    try
    {
        //Code like A = string(NULL) that throws an exception
    }
    catch(std::exception& ex)
    {
        cout<<"in A : " << ex.what();
        throw ex;
    }
}
void B()
{
   try
   {
       A();
   }
   catch(std::exception& ex)
   {
       cout<<"in B : " << ex.what();
   }
}
After running this I got this result:
in A: basic_string::_M_construct null not valid
in B: std::exception
As you can see, ex.what() works OK in function A and tell me the correct description, but in B ex.what() tells me just std::exception. Why does this happen?
Am I throwing something different or wrong in the catch clause of function A? How do I throw a nested exception so that I can get the exact exception description in B?
 
     
     
     
     
    