encode errors and pipe them around