Add error output to main.c

targets #338