eldenmoon commented on code in PR #38035: URL: https://github.com/apache/doris/pull/38035#discussion_r1696175744
########## be/src/common/exception.h: ########## @@ -131,3 +131,49 @@ inline const std::string& Exception::to_string() const { } \ } \ } while (0); + +#define HANDLE_EXCEPTION_IF_CATCH_EXCEPTION(stmt, handle_exception) \ + do { \ + try { \ + doris::enable_thread_catch_bad_alloc++; \ + Defer defer {[&]() { doris::enable_thread_catch_bad_alloc--; }}; \ + { \ + Status _status_ = (stmt); \ + if (UNLIKELY(!_status_.ok())) { \ + handle_exception(doris::Exception()); \ + return _status_; \ + } \ + } \ + } catch (const doris::Exception& e) { \ + handle_exception(e); \ + if (e.code() == doris::ErrorCode::MEM_ALLOC_FAILED) { \ + return Status::MemoryLimitExceeded(fmt::format( \ + "PreCatch error code:{}, {}, __FILE__:{}, __LINE__:{}, __FUNCTION__:{}", \ + e.code(), e.to_string(), __FILE__, __LINE__, __PRETTY_FUNCTION__)); \ + } \ + return Status::Error<false>(e.code(), e.to_string()); \ + } \ + } while (0); + +#define HANDLE_ERROR_IF_CATCH_EXCEPTION_OR_RETURN_ERROR(stmt, handle_error) \ Review Comment: using defer -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org