fix issue in router to handle error.