handle nil objects in the output strings so the correct stack trace can be shown

Some gem (thrift 0.08) returns nil objects for the output strings, and cause stack trace incorrectly showing errors in rake.