Use err_flush_to_string for EMS error handling

Added to NDF years ago. This saves having to do the stack unrolling
manually.