Added option to include onError function in config