Better error message capture