added error event handling to client
merge from HEAD