Check for errors when running arbitrary code

The stack is only cleared if the call is successful, so that in errors one can get the error string at index -1.