sh test.sh > error.log
Of course you can.
The tSystem component provides to catch both output streams of a process to get it as global variabale.
You can access the content as string while the job is running and after the job finished. It is necessary to setup the options Standard Output and error Output to: "to global variable"
Here an example (in case your component in the job is the first of tSystem components):
((String) globalMap.get("tSystem_1_OUTPUT")) returns the normal output
((String) globalMap.get("tSystem_1_ERROROUTPUT")) returns the error output content.
You can use the tParallel component to run your job and in parallel to it a different subjob checking the output.
Yes unfortunately the tParallel component is not part of the open source release. In this case you can only check the job output at its end.
Or you export the job as a standalone job and sends the outputs to a file (as Sabrina already suggested) and another job running parallel (checks the output file and sends the stack trace).
Why do you need the stack trace in a email? I would design the job and the tDie's in a way to have more meaningful messages. From my point of view this is a be far better approach than reading stacktraces to find the problem.