added interface for error callbacks
added code to set error event callback and code to handle error
responses