fix bug when logging error