autoinsert template like exception handler, match the first, then exit