Of course the flaw in this whole technique is if the error message actually contains a right-bracket, you won't get the whole thing. If you know this will never happen, that won't be a problem, but the original code is somewhat more robust in the face of unknown input.