unified error handling, move most logic from renderer to router