Adding onError handler
adding onError method