Also Instead of error message why dont you try wiyh warning messages or information messages. Can you pls give the code that you are using.
I would also recommend you to put a breakpoint there and see the reachability of the code. See whether the screen is lost immediatly aftet message line or it goes further.
Regards,
Satish