modified to find error code and truncated R script name
without the full path