Capturing maxima error messages as strings



I'm trying to capture error messages which maxima produces as
strings.  I'd like to write something like

s:errormsg();

and then be able to use s as a maxima string.  

This will be part of some code which returns either the result of
evaluating a block, or the error as a string.

Also, and this is probably a very stupid question, but there seem to be a
number of levels at which the errors are generated.  Syntax errors are not
captured by errormsg().  For an example, see below.  What are, and how may
I capture all the various error messages as stings?

Many thanks

Chris

(C1) p:[1,2,3]$ 
(C2) p[4];
Improper index to list or matrix
 -- an error.  Quitting.  To debug this try DEBUGMODE(TRUE);)
(C3) 2x;Incorrect syntax: x is not an infix operator
2x;
 ^
(C3) errormsg();
Improper index to list or matrix
(D3)                     DONE