effectively capture and reset last error code