I'm not sure exactly what you are asking. If it is about retrieving the line, error stack etc. from C, Tcl_GetReturnOptions will give you a dictionary with the same information. If you are asking how to write to the appropriate channel, use Tcl_GetStdChannel to retrieve stdout or stderr and then one of the Tcl_Write* functions to write to it. It's probably not a good idea to use printf etc. directly because you will bypass any channel settings like encoding, line end translation etc.
/Ashok