Still, if you really want to do this, you can do the following:
str errorMessage; try { throw error('Some error message being thrown here'); } catch { errorMessage = infolog.text(infologLine()); } print errorMessage; pause;
The infolog.text() method gets the text of the line number argumented. The infologLine() global method gets the total of lines in the Infolog. The code above always gets the last line added to the Infolog.
The code above will not hide the Infolog too. If you want to capture the last error message and then hide the infolog, or clear its contents, you can add a call to the infolog.clear() method right after you fetch the error message.
One thing to point out is that the infolog.text() method returns you the contents of the line number specified as text. This means it'll cast the line icon to a string too, making it become a tab character. You'll have to parse the returned string, because it'll be something like " Some error message being thrown here".
You can simply add a call to the strRem method to remove the tab character:
errorMessage = strRem(errorMessage, '\t');