handle errors properly when protocol errors occured