This is an automated email from the ASF dual-hosted git repository.

zclll pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new e66e76fabe9 [feat](common) Add DORIS_CHECK macro for precondition 
assertions (#60935)
e66e76fabe9 is described below

commit e66e76fabe994605dbe470b7bd8023b062d9b2b0
Author: zclllyybb <[email protected]>
AuthorDate: Mon Mar 2 14:12:28 2026 +0800

    [feat](common) Add DORIS_CHECK macro for precondition assertions (#60935)
    
    Introduce DORIS_CHECK macro to enforce preconditions with fail-fast
    behavior:
    - Throws FatalError exception when assertion fails
    - Replaces defensive if-checks with explicit precondition validation
    - Follows guideline: crash on unexpected conditions rather than continue
    execution
---
 be/src/common/status.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/be/src/common/status.h b/be/src/common/status.h
index 9ef41ccf0b6..e074e3a8ed0 100644
--- a/be/src/common/status.h
+++ b/be/src/common/status.h
@@ -757,6 +757,14 @@ using ResultError = unexpected<Status>;
         std::forward<T>(res).value();                                          
                 \
     })
 
+// core in Debug mode, exception in Release mode.
+#define DORIS_CHECK(stmt)                                                      
          \
+    do {                                                                       
          \
+        if (!static_cast<bool>(stmt)) [[unlikely]] {                           
          \
+            throw Exception(Status::FatalError(fmt::format("Check failed: {}", 
#stmt))); \
+        }                                                                      
          \
+    } while (false)
+
 } // namespace doris
 
 // specify formatter for Status


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

Reply via email to