gemini-code-assist[bot] commented on code in PR #240:
URL: https://github.com/apache/tvm-ffi/pull/240#discussion_r2505913620


##########
include/tvm/ffi/error.h:
##########
@@ -225,17 +225,25 @@ class Error : public ObjectRef, public std::exception {
     obj->update_backtrace(obj, backtrace_str, update_mode);
   }
 
+  /*!
+   * \brief Get the full message of the error, including kind, message and 
traceback.
+   * \return The full message of the error object.
+   */
+  std::string FullMessage() const {
+    ErrorObj* obj = static_cast<ErrorObj*>(data_.get());
+    return (std::string("Traceback (most recent call last):\n") + 
TracebackMostRecentCallLast() +
+            std::string(obj->kind.data, obj->kind.size) + std::string(": ") +
+            std::string(obj->message.data, obj->message.size) + '\n');

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   To improve efficiency and readability, consider using `std::ostringstream` 
to construct the full message. This avoids creating multiple temporary 
`std::string` objects during concatenation and is a common pattern in this 
codebase.
   
   ```c
       ErrorObj* obj = static_cast<ErrorObj*>(data_.get());
       std::ostringstream os;
       os << "Traceback (most recent call last):\n"
          << TracebackMostRecentCallLast()
          << std::string_view(obj->kind.data, obj->kind.size) << ": "
          << std::string_view(obj->message.data, obj->message.size) << '\n';
       return os.str();
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to