Ther above code will NOT return the Message that is printed to the Message Tab. The minute you use try - Catch you lose that.
I too am looking for a way to get the message that is actually returned as it provides much more info.
Following TSQL:
RESTORE VERIFYONLY FROM DISK = 'F:\Temp\SkDataDemo-20140929203m7.bak'
If I deliberately use a bad file name for example I get the following to the screen:
Msg 3201, Level 16, State 2, Line 3
Cannot open backup device 'F:\Temp\SkDataDemo-20140929203m7.bak'. Operating system error 2(The system cannot find the file specified.).
Msg 3013, Level 16, State 1, Line 3
VERIFY DATABASE is terminating abnormally.
If I wrapper the above line in a TRY-CATCH all I get back is:
VERIFY DATABASE is terminating abnormally.
I would REALLY like to capture the full message.