| 134 | } |
| 135 | |
| 136 | Status MakeErrorStream::Impl::GetStatus() { |
| 137 | // Note: error messages refer to the public MakeErrorStream class. |
| 138 | |
| 139 | // Getting a Status object out more than once is not harmful, but |
| 140 | // it doesn't match the expected pattern, where the stream is constructed |
| 141 | // as a temporary, loaded with a message, and then casted to Status. |
| 142 | if (is_done_) { |
| 143 | LOG(ERROR) << "MakeErrorStream got Status more than once: " << file_ << ":" |
| 144 | << line_ << " " << stream_.str(); |
| 145 | } |
| 146 | |
| 147 | is_done_ = true; |
| 148 | |
| 149 | const string& stream_str = stream_.str(); |
| 150 | const string str = prior_message_handling_ == kAppendToPriorMessage |
| 151 | ? absl::StrCat(prior_message_, stream_str) |
| 152 | : absl::StrCat(stream_str, prior_message_); |
| 153 | if (TF_PREDICT_FALSE(str.empty())) { |
| 154 | return MakeError( |
| 155 | file_, line_, code_, |
| 156 | absl::StrCat(str, "Error without message at ", file_, ":", line_), |
| 157 | true /* should_log */, tensorflow::ERROR /* log_severity */, |
| 158 | should_log_stack_trace_); |
| 159 | } else { |
| 160 | return MakeError(file_, line_, code_, str, should_log_, log_severity_, |
| 161 | should_log_stack_trace_); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | void MakeErrorStream::Impl::CheckNotDone() const { |
| 166 | if (is_done_) { |
no test coverage detected