Log response documents in case of errors

Fix #1156