Use std::exeption_ptr() check instead of NULL cast, which is not supported in gcc 4.4