Prepare response end for error handling
Added error `invalid response`
Added error `not json`
Added comment