pass error handler when using pipe to make code robust