Change callback onError method to be generic