main: handle except

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>