This code should work, however currently throws a null reference exception because the existing cause does not have an exception associated.
try
{
recorder.BeginSubsegment("child1");
try
{
try
{
recorder.BeginSubsegment("child2");
throw new AmazonServiceException();
}
catch (AmazonServiceException e)
{
recorder.AddException(e);
recorder.EndSubsegment();
throw;
}
}
catch (AmazonServiceException e)
{
recorder.AddException(e);
recorder.EndSubsegment();
throw new EntityNotAvailableException("Dummy message", e);
}
}
catch (EntityNotAvailableException e)
{
recorder.AddException(e);
recorder.EndSegment();
}