add on_error callback option
add example for on_error callback option