network: Split out basic error handling into trait.