drain: better error handling without exceptions