Moving error handling into routes