Is there any way to pop up a message box when check(xxx) failed

Is there any builtin way to achieve it , or is there any way to wright about it ?

what we want is:
when the c++ code is under some situation, the code block the current game, and pop up an message box with stack info.