Sorry my bad, I didn't check the backend code, I assumed that it is coming from psycopg2 and so I was focusing it to remove from client side :(
PFA updated patch.
I think it needs to be a bit smarter than that. Whilst it works well for the "empty query" message, it doesn't work well for errors that have full details. For instance, instead of: