| 132 | } // namespace |
| 133 | |
| 134 | Maybe<std::string> FormatErrorStr(const std::shared_ptr<StackedError>& error) { |
| 135 | std::stringstream ss; |
| 136 | ss << error->error_proto()->msg(); |
| 137 | ss << error->error_proto()->frame_msg(); |
| 138 | // Get msg from stack frame of error proto |
| 139 | for (auto iter = error->stack_frame().rbegin(); iter < error->stack_frame().rend(); iter++) { |
| 140 | auto stack_frame = *iter; |
| 141 | ss << FormatFileOfStackFrame(stack_frame->file()) << FormatLineOfStackFrame(stack_frame->line()) |
| 142 | << FormatFunctionOfStackFrame(stack_frame->function()) |
| 143 | << *JUST(FormatMsgOfStackFrame(stack_frame->code_text(), |
| 144 | iter == error->stack_frame().rend() - 1)); |
| 145 | } |
| 146 | // Get msg from error type of error proto |
| 147 | std::string msg_of_error_type = *JUST(FormatMsgOfErrorType(error)); |
| 148 | if (msg_of_error_type.size() != 0) { ss << "\n" << msg_of_error_type; } |
| 149 | return ss.str(); |
| 150 | } |
| 151 | |
| 152 | } // namespace oneflow |
no test coverage detected