add onError handler