Using functors to handle errors without massive amounts of repeated code