correctly format output with errors