Handle error and success responses