Catch errors based on output code and emit then properly