clean buffer in error_handler