Usually you would use stderr for error messages.
If you run a program on the command line, you can capture its stdout and/or stderr
myprogram.exe > stdout.txt
will capture anything written by myprogram.exe to stdout and place it in stdout.txt. However, stuff written to stderr will not be put into stdout.txt. Thus you can capture the program’s regular output without capturing error messages.