kou commented on code in PR #36273:
URL: https://github.com/apache/arrow/pull/36273#discussion_r1240307594


##########
matlab/src/cpp/arrow/matlab/error/error.h:
##########
@@ -17,19 +17,154 @@
 
 #pragma once
 
-
 #include "arrow/status.h"
 #include "libmexclass/error/Error.h"
 
-#include <string_view>
-
+//
+// MATLAB_ERROR_IF_NOT_OK(expr, id)
+//
+//  --- Description ---
+//
+// A macro used to return an error to MATLAB if the arrow::Status returned
+// by the specified expression is not "OK" (i.e. error).
+//
+// **NOTE**: This macro should be used inside of the static make() member 
function for a
+//           Proxy class. Use MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT inside of a 
non-static
+//           Proxy member function.
+//
+// --- Arguments ---
+//
+// lhs - variable name to assign to (e.g. auto array)
+// expr - expression that returns an arrow::Status (e.g. builder.Append(...))
+// id - MATLAB error ID string (const char* - 
"arrow:matlab:proxy:make:FailedConstruction")
+//
+// --- Example ---
+//
+// MATLAB_ERROR_IF_NOT_OK(builder.Append(...), 
error::BUILDER_FAILED_TO_APPEND);
+//
 #define MATLAB_ERROR_IF_NOT_OK(expr, id)                               \
     do {                                                               \
         arrow::Status _status = (expr);                                \
         if (!_status.ok()) {                                           \
             return libmexclass::error::Error{(id), _status.message()}; \
         }                                                              \
-    } while (0)
+    } while (0)                                                        \

Review Comment:
   ```suggestion
       } while (0)
   ```



##########
matlab/src/cpp/arrow/matlab/error/error.h:
##########
@@ -17,19 +17,154 @@
 
 #pragma once
 
-
 #include "arrow/status.h"
 #include "libmexclass/error/Error.h"
 
-#include <string_view>
-
+//
+// MATLAB_ERROR_IF_NOT_OK(expr, id)
+//
+//  --- Description ---
+//
+// A macro used to return an error to MATLAB if the arrow::Status returned
+// by the specified expression is not "OK" (i.e. error).
+//
+// **NOTE**: This macro should be used inside of the static make() member 
function for a
+//           Proxy class. Use MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT inside of a 
non-static
+//           Proxy member function.
+//
+// --- Arguments ---
+//
+// lhs - variable name to assign to (e.g. auto array)

Review Comment:
   ```suggestion
   ```



##########
matlab/src/cpp/arrow/matlab/error/error.h:
##########
@@ -17,19 +17,154 @@
 
 #pragma once
 
-
 #include "arrow/status.h"
 #include "libmexclass/error/Error.h"
 
-#include <string_view>
-
+//
+// MATLAB_ERROR_IF_NOT_OK(expr, id)
+//
+//  --- Description ---
+//
+// A macro used to return an error to MATLAB if the arrow::Status returned
+// by the specified expression is not "OK" (i.e. error).
+//
+// **NOTE**: This macro should be used inside of the static make() member 
function for a
+//           Proxy class. Use MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT inside of a 
non-static
+//           Proxy member function.
+//
+// --- Arguments ---
+//
+// lhs - variable name to assign to (e.g. auto array)
+// expr - expression that returns an arrow::Status (e.g. builder.Append(...))
+// id - MATLAB error ID string (const char* - 
"arrow:matlab:proxy:make:FailedConstruction")
+//
+// --- Example ---
+//
+// MATLAB_ERROR_IF_NOT_OK(builder.Append(...), 
error::BUILDER_FAILED_TO_APPEND);
+//
 #define MATLAB_ERROR_IF_NOT_OK(expr, id)                               \
     do {                                                               \
         arrow::Status _status = (expr);                                \
         if (!_status.ok()) {                                           \
             return libmexclass::error::Error{(id), _status.message()}; \
         }                                                              \
-    } while (0)
+    } while (0)                                                        \
+
+//
+// MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(expr, context, id)
+//
+//  --- Description ---
+//
+// A macro used to return an error to MATLAB if the arrow::Status returned
+// by the specified expression is not "OK" (i.e. error).
+//
+// **NOTE**: This macro should be used inside of a non-static member function 
of a
+//           Proxy class which has a libmexclass::proxy::method::Context as an 
input argument.
+//           Use MATLAB_ERROR_IF_NOT_OK inside of a Proxy static make() member 
function.
+//
+// --- Arguments ---
+//
+// lhs - variable name to assign to (e.g. auto array)
+// expr - expression that returns an arrow::Status (e.g. builder.Append(...))
+// context - libmexclass::proxy::method::Context context input to a Proxy 
method
+// id - MATLAB error ID string (const char* - 
"arrow:matlab:proxy:make:FailedConstruction")
+//
+// --- Example ---
+//
+// MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(builder.Append(...), context, 
error::BUILDER_FAILED_TO_APPEND);
+//
+// #define MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(expr, context, id)              
  \
+//     do {                                                                    
  \
+//         arrow::Status _status = (expr);                                     
  \
+//         if (!_status.ok()) {                                                
  \
+//             context.error = libmexclass::error::Error{id, 
_status.message()}; \
+//             return;                                                         
  \
+//         }                                                                   
  \
+//     } while (0)                                                             
  \
+
+#define MATLAB_ASSIGN_OR_RAISE_NAME(x, y) \
+    ARROW_CONCAT(x, y)                    \
+
+#define MATLAB_ASSIGN_OR_ERROR_IMPL(result_name, lhs, rexpr, id) \
+    auto&& result_name = (rexpr);                                \
+    MATLAB_ERROR_IF_NOT_OK(result_name.status(), id);            \
+    lhs = std::move(result_name).ValueUnsafe();                  \

Review Comment:
   ```suggestion
       lhs = std::move(result_name).ValueUnsafe();
   ```



##########
matlab/src/cpp/arrow/matlab/error/error.h:
##########
@@ -17,19 +17,154 @@
 
 #pragma once
 
-
 #include "arrow/status.h"
 #include "libmexclass/error/Error.h"
 
-#include <string_view>
-
+//
+// MATLAB_ERROR_IF_NOT_OK(expr, id)
+//
+//  --- Description ---
+//
+// A macro used to return an error to MATLAB if the arrow::Status returned
+// by the specified expression is not "OK" (i.e. error).
+//
+// **NOTE**: This macro should be used inside of the static make() member 
function for a
+//           Proxy class. Use MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT inside of a 
non-static
+//           Proxy member function.
+//
+// --- Arguments ---
+//
+// lhs - variable name to assign to (e.g. auto array)
+// expr - expression that returns an arrow::Status (e.g. builder.Append(...))
+// id - MATLAB error ID string (const char* - 
"arrow:matlab:proxy:make:FailedConstruction")
+//
+// --- Example ---
+//
+// MATLAB_ERROR_IF_NOT_OK(builder.Append(...), 
error::BUILDER_FAILED_TO_APPEND);
+//
 #define MATLAB_ERROR_IF_NOT_OK(expr, id)                               \
     do {                                                               \
         arrow::Status _status = (expr);                                \
         if (!_status.ok()) {                                           \
             return libmexclass::error::Error{(id), _status.message()}; \
         }                                                              \
-    } while (0)
+    } while (0)                                                        \
+
+//
+// MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(expr, context, id)
+//
+//  --- Description ---
+//
+// A macro used to return an error to MATLAB if the arrow::Status returned
+// by the specified expression is not "OK" (i.e. error).
+//
+// **NOTE**: This macro should be used inside of a non-static member function 
of a
+//           Proxy class which has a libmexclass::proxy::method::Context as an 
input argument.
+//           Use MATLAB_ERROR_IF_NOT_OK inside of a Proxy static make() member 
function.
+//
+// --- Arguments ---
+//
+// lhs - variable name to assign to (e.g. auto array)

Review Comment:
   ```suggestion
   ```



##########
matlab/src/cpp/arrow/matlab/error/error.h:
##########
@@ -17,19 +17,154 @@
 
 #pragma once
 
-
 #include "arrow/status.h"
 #include "libmexclass/error/Error.h"
 
-#include <string_view>
-
+//
+// MATLAB_ERROR_IF_NOT_OK(expr, id)
+//
+//  --- Description ---
+//
+// A macro used to return an error to MATLAB if the arrow::Status returned
+// by the specified expression is not "OK" (i.e. error).
+//
+// **NOTE**: This macro should be used inside of the static make() member 
function for a
+//           Proxy class. Use MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT inside of a 
non-static
+//           Proxy member function.
+//
+// --- Arguments ---
+//
+// lhs - variable name to assign to (e.g. auto array)
+// expr - expression that returns an arrow::Status (e.g. builder.Append(...))
+// id - MATLAB error ID string (const char* - 
"arrow:matlab:proxy:make:FailedConstruction")
+//
+// --- Example ---
+//
+// MATLAB_ERROR_IF_NOT_OK(builder.Append(...), 
error::BUILDER_FAILED_TO_APPEND);
+//
 #define MATLAB_ERROR_IF_NOT_OK(expr, id)                               \
     do {                                                               \
         arrow::Status _status = (expr);                                \
         if (!_status.ok()) {                                           \
             return libmexclass::error::Error{(id), _status.message()}; \
         }                                                              \
-    } while (0)
+    } while (0)                                                        \
+
+//
+// MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(expr, context, id)
+//
+//  --- Description ---
+//
+// A macro used to return an error to MATLAB if the arrow::Status returned
+// by the specified expression is not "OK" (i.e. error).
+//
+// **NOTE**: This macro should be used inside of a non-static member function 
of a
+//           Proxy class which has a libmexclass::proxy::method::Context as an 
input argument.
+//           Use MATLAB_ERROR_IF_NOT_OK inside of a Proxy static make() member 
function.
+//
+// --- Arguments ---
+//
+// lhs - variable name to assign to (e.g. auto array)
+// expr - expression that returns an arrow::Status (e.g. builder.Append(...))
+// context - libmexclass::proxy::method::Context context input to a Proxy 
method
+// id - MATLAB error ID string (const char* - 
"arrow:matlab:proxy:make:FailedConstruction")
+//
+// --- Example ---
+//
+// MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(builder.Append(...), context, 
error::BUILDER_FAILED_TO_APPEND);
+//
+// #define MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(expr, context, id)              
  \
+//     do {                                                                    
  \
+//         arrow::Status _status = (expr);                                     
  \
+//         if (!_status.ok()) {                                                
  \
+//             context.error = libmexclass::error::Error{id, 
_status.message()}; \
+//             return;                                                         
  \
+//         }                                                                   
  \
+//     } while (0)                                                             
  \
+
+#define MATLAB_ASSIGN_OR_RAISE_NAME(x, y) \
+    ARROW_CONCAT(x, y)                    \

Review Comment:
   ```suggestion
       ARROW_CONCAT(x, y)
   ```



##########
matlab/src/cpp/arrow/matlab/error/error.h:
##########
@@ -17,19 +17,154 @@
 
 #pragma once
 
-
 #include "arrow/status.h"
 #include "libmexclass/error/Error.h"
 
-#include <string_view>
-
+//
+// MATLAB_ERROR_IF_NOT_OK(expr, id)
+//
+//  --- Description ---
+//
+// A macro used to return an error to MATLAB if the arrow::Status returned
+// by the specified expression is not "OK" (i.e. error).
+//
+// **NOTE**: This macro should be used inside of the static make() member 
function for a
+//           Proxy class. Use MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT inside of a 
non-static
+//           Proxy member function.
+//
+// --- Arguments ---
+//
+// lhs - variable name to assign to (e.g. auto array)
+// expr - expression that returns an arrow::Status (e.g. builder.Append(...))
+// id - MATLAB error ID string (const char* - 
"arrow:matlab:proxy:make:FailedConstruction")
+//
+// --- Example ---
+//
+// MATLAB_ERROR_IF_NOT_OK(builder.Append(...), 
error::BUILDER_FAILED_TO_APPEND);
+//
 #define MATLAB_ERROR_IF_NOT_OK(expr, id)                               \
     do {                                                               \
         arrow::Status _status = (expr);                                \
         if (!_status.ok()) {                                           \
             return libmexclass::error::Error{(id), _status.message()}; \
         }                                                              \
-    } while (0)
+    } while (0)                                                        \
+
+//
+// MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(expr, context, id)
+//
+//  --- Description ---
+//
+// A macro used to return an error to MATLAB if the arrow::Status returned
+// by the specified expression is not "OK" (i.e. error).
+//
+// **NOTE**: This macro should be used inside of a non-static member function 
of a
+//           Proxy class which has a libmexclass::proxy::method::Context as an 
input argument.
+//           Use MATLAB_ERROR_IF_NOT_OK inside of a Proxy static make() member 
function.
+//
+// --- Arguments ---
+//
+// lhs - variable name to assign to (e.g. auto array)
+// expr - expression that returns an arrow::Status (e.g. builder.Append(...))
+// context - libmexclass::proxy::method::Context context input to a Proxy 
method
+// id - MATLAB error ID string (const char* - 
"arrow:matlab:proxy:make:FailedConstruction")
+//
+// --- Example ---
+//
+// MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(builder.Append(...), context, 
error::BUILDER_FAILED_TO_APPEND);
+//
+// #define MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(expr, context, id)              
  \
+//     do {                                                                    
  \
+//         arrow::Status _status = (expr);                                     
  \
+//         if (!_status.ok()) {                                                
  \
+//             context.error = libmexclass::error::Error{id, 
_status.message()}; \
+//             return;                                                         
  \
+//         }                                                                   
  \
+//     } while (0)                                                             
  \
+
+#define MATLAB_ASSIGN_OR_RAISE_NAME(x, y) \

Review Comment:
   How about using `ERROR` instead of `RAISE` like others?
   
   ```suggestion
   #define MATLAB_ASSIGN_OR_ERROR_NAME(x, y) \
   ```



-- 
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]

Reply via email to