diff --git a/paddle/platform/enforce.h b/paddle/platform/enforce.h index ab474508d9877e1d5dfa5eebf8196d82e43b9574..89a948e495e0a98914d93d1ab9a41952163b8875 100644 --- a/paddle/platform/enforce.h +++ b/paddle/platform/enforce.h @@ -127,9 +127,15 @@ inline typename std::enable_if::type throw_on_error( #endif // PADDLE_ONLY_CPU -template -inline void throw_on_error(T* e) { - throw_on_error(e != nullptr, ""); +template +inline typename std::enable_if::value, void>::type +throw_on_error(T stat, const Args&... args) { + if (stat == nullptr) { + return; + } else { + throw std::runtime_error("Pointer value is nullptr: " + + string::Sprintf(args...)); + } } template