Fix raise exception error and improve debug info