This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 7ae51c856e [refactor](unify exception) unify exception definition and
error code (#18006)
7ae51c856e is described below
commit 7ae51c856e5d5db7b456fe82e0c36f253f145e85
Author: yiguolei <[email protected]>
AuthorDate: Sat Mar 25 12:41:07 2023 +0800
[refactor](unify exception) unify exception definition and error code
(#18006)
* [refactor](unify exception) unify exception definition and error code
---------
Co-authored-by: yiguolei <[email protected]>
---
be/src/common/status.h | 1 +
be/src/exprs/rpc_fn_comm.h | 1 -
be/src/util/CMakeLists.txt | 1 -
be/src/util/exception.cpp | 35 ---
be/src/util/exception.h | 22 --
be/src/util/proto_util.h | 9 +-
be/src/vec/CMakeLists.txt | 1 -
.../vec/aggregate_functions/aggregate_function.h | 1 -
.../aggregate_functions/aggregate_function_rpc.h | 1 -
be/src/vec/columns/column_decimal.cpp | 1 -
be/src/vec/columns/column_vector.cpp | 1 -
be/src/vec/common/allocator.h | 13 +-
be/src/vec/common/assert_cast.h | 1 -
be/src/vec/common/exception.cpp | 208 ---------------
be/src/vec/common/exception.h | 288 ---------------------
be/src/vec/common/hash_table/hash_table.h | 5 +-
be/src/vec/common/typeid_cast.h | 12 +-
be/src/vec/core/block.cpp | 8 +-
be/src/vec/core/field.h | 1 -
be/src/vec/data_types/data_type_nothing.h | 2 -
be/src/vec/io/io_helper.h | 8 +-
21 files changed, 22 insertions(+), 598 deletions(-)
diff --git a/be/src/common/status.h b/be/src/common/status.h
index ae0509cdd7..330f8114bf 100644
--- a/be/src/common/status.h
+++ b/be/src/common/status.h
@@ -71,6 +71,7 @@ E(FILE_FORMAT_ERROR, -119);
E(EVAL_CONJUNCTS_ERROR, -120);
E(COPY_FILE_ERROR, -121);
E(FILE_ALREADY_EXIST, -122);
+E(BAD_CAST, -123);
E(CALL_SEQUENCE_ERROR, -202);
E(BUFFER_OVERFLOW, -204);
E(CONFIG_ERROR, -205);
diff --git a/be/src/exprs/rpc_fn_comm.h b/be/src/exprs/rpc_fn_comm.h
index 1849c0a2d2..1352c3d06c 100644
--- a/be/src/exprs/rpc_fn_comm.h
+++ b/be/src/exprs/rpc_fn_comm.h
@@ -31,7 +31,6 @@
#include "vec/columns/column_string.h"
#include "vec/columns/column_vector.h"
#include "vec/columns/columns_number.h"
-#include "vec/common/exception.h"
#include "vec/common/string_ref.h"
#include "vec/core/block.h"
#include "vec/core/column_numbers.h"
diff --git a/be/src/util/CMakeLists.txt b/be/src/util/CMakeLists.txt
index b6d5f32e1e..524d5d372e 100644
--- a/be/src/util/CMakeLists.txt
+++ b/be/src/util/CMakeLists.txt
@@ -101,7 +101,6 @@ set(UTIL_FILES
telemetry/open_telemetry_scop_wrapper.hpp
quantile_state.cpp
jni-util.cpp
- exception.cpp
libjvm_loader.cpp
jni_native_method.cpp
)
diff --git a/be/src/util/exception.cpp b/be/src/util/exception.cpp
deleted file mode 100644
index ab525b4412..0000000000
--- a/be/src/util/exception.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "exception.h"
-
-#ifdef USE_LIBCPP
-#include <cxxabi.h>
-
-#include <typeinfo>
-#endif
-
-const char* get_current_exception_type_name(const std::exception_ptr&
exception_ptr) {
-#ifdef USE_LIBCPP
- int status;
- return exception_ptr ?
abi::__cxa_demangle(abi::__cxa_current_exception_type()->name(), nullptr,
- nullptr, &status)
- : "null";
-#else
- return exception_ptr ? exception_ptr.__cxa_exception_type()->name() :
"null";
-#endif
-}
diff --git a/be/src/util/exception.h b/be/src/util/exception.h
deleted file mode 100644
index 0cfb506013..0000000000
--- a/be/src/util/exception.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#pragma once
-
-#include <exception>
-
-const char* get_current_exception_type_name(const std::exception_ptr&
exception_ptr);
diff --git a/be/src/util/proto_util.h b/be/src/util/proto_util.h
index 79a1e0866c..2741092d80 100644
--- a/be/src/util/proto_util.h
+++ b/be/src/util/proto_util.h
@@ -22,7 +22,6 @@
#include "common/config.h"
#include "common/status.h"
-#include "exception.h"
#include "network_util.h"
#include "runtime/exec_env.h"
#include "runtime/runtime_state.h"
@@ -160,10 +159,8 @@ Status request_embed_attachment(Params* brpc_request,
const std::string& data, C
try {
attachment.append(data);
} catch (...) {
- std::exception_ptr p = std::current_exception();
LOG(WARNING) << "Try to alloc " << data_size
- << " bytes for append data to attachment failed. "
- << get_current_exception_type_name(p);
+ << " bytes for append data to attachment failed. ";
return Status::MemoryAllocFailed("request embed attachment failed to
memcpy {} bytes",
data_size);
}
@@ -201,10 +198,8 @@ Status attachment_extract_request(const Params*
brpc_request, brpc::Controller*
try {
io_buf.copy_to(data, data_size, sizeof(data_size) +
sizeof(req_str_size) + req_str_size);
} catch (...) {
- std::exception_ptr p = std::current_exception();
LOG(WARNING) << "Try to alloc " << data_size
- << " bytes for extract data from attachment failed. "
- << get_current_exception_type_name(p);
+ << " bytes for extract data from attachment failed. ";
return Status::MemoryAllocFailed("attachment extract request failed to
memcpy {} bytes",
data_size);
}
diff --git a/be/src/vec/CMakeLists.txt b/be/src/vec/CMakeLists.txt
index 36b89f929b..3943204bce 100644
--- a/be/src/vec/CMakeLists.txt
+++ b/be/src/vec/CMakeLists.txt
@@ -63,7 +63,6 @@ set(VEC_FILES
json/path_in_data.cpp
common/schema_util.cpp
common/demangle.cpp
- common/exception.cpp
common/mremap.cpp
common/pod_array.cpp
common/string_ref.cpp
diff --git a/be/src/vec/aggregate_functions/aggregate_function.h
b/be/src/vec/aggregate_functions/aggregate_function.h
index e86415b729..c55612ec15 100644
--- a/be/src/vec/aggregate_functions/aggregate_function.h
+++ b/be/src/vec/aggregate_functions/aggregate_function.h
@@ -23,7 +23,6 @@
#include <parallel_hashmap/phmap.h>
#include "vec/columns/column_complex.h"
-#include "vec/common/exception.h"
#include "vec/core/block.h"
#include "vec/core/column_numbers.h"
#include "vec/core/field.h"
diff --git a/be/src/vec/aggregate_functions/aggregate_function_rpc.h
b/be/src/vec/aggregate_functions/aggregate_function_rpc.h
index d102055ced..ea106150ee 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_rpc.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_rpc.h
@@ -33,7 +33,6 @@
#include "vec/columns/column_string.h"
#include "vec/columns/column_vector.h"
#include "vec/columns/columns_number.h"
-#include "vec/common/exception.h"
#include "vec/common/string_ref.h"
#include "vec/core/block.h"
#include "vec/core/column_numbers.h"
diff --git a/be/src/vec/columns/column_decimal.cpp
b/be/src/vec/columns/column_decimal.cpp
index 778a0b83d3..7731e05389 100644
--- a/be/src/vec/columns/column_decimal.cpp
+++ b/be/src/vec/columns/column_decimal.cpp
@@ -26,7 +26,6 @@
#include "vec/columns/columns_common.h"
#include "vec/common/arena.h"
#include "vec/common/assert_cast.h"
-#include "vec/common/exception.h"
#include "vec/common/sip_hash.h"
#include "vec/common/unaligned.h"
#include "vec/core/sort_block.h"
diff --git a/be/src/vec/columns/column_vector.cpp
b/be/src/vec/columns/column_vector.cpp
index e852f555f1..4deaa46b69 100644
--- a/be/src/vec/columns/column_vector.cpp
+++ b/be/src/vec/columns/column_vector.cpp
@@ -33,7 +33,6 @@
#include "vec/common/arena.h"
#include "vec/common/assert_cast.h"
#include "vec/common/bit_cast.h"
-#include "vec/common/exception.h"
#include "vec/common/nan_utils.h"
#include "vec/common/sip_hash.h"
#include "vec/common/unaligned.h"
diff --git a/be/src/vec/common/allocator.h b/be/src/vec/common/allocator.h
index 22b69c1854..6287c837b6 100644
--- a/be/src/vec/common/allocator.h
+++ b/be/src/vec/common/allocator.h
@@ -25,8 +25,6 @@
#include <fmt/format.h>
#include <string.h>
-#include <exception>
-
#include "common/config.h"
#include "common/status.h"
#include "runtime/memory/chunk.h"
@@ -55,8 +53,8 @@
/// Thread sanitizer does not intercept mremap. The usage of mremap will lead
to false positives.
#define DISABLE_MREMAP 1
#endif
+#include "common/exception.h"
#include "vec/common/allocator_fwd.h"
-#include "vec/common/exception.h"
#include "vec/common/mremap.h"
/// Required for older Darwin builds, that lack definition of MAP_ANONYMOUS
@@ -139,11 +137,10 @@ public:
if (size >= MMAP_THRESHOLD) {
if (alignment > MMAP_MIN_ALIGNMENT)
- throw doris::vectorized::Exception(
- fmt::format(
- "Too large alignment {}: more than page size
when allocating {}.",
- alignment, size),
- doris::TStatusCode::VEC_BAD_ARGUMENTS);
+ throw doris::Exception(
+ doris::ErrorCode::INVALID_ARGUMENT,
+ "Too large alignment {}: more than page size when
allocating {}.",
+ alignment, size);
if (!TRY_CONSUME_THREAD_MEM_TRACKER(size)) {
RETURN_BAD_ALLOC_IF_PRE_CATCH(
diff --git a/be/src/vec/common/assert_cast.h b/be/src/vec/common/assert_cast.h
index 0c3d32ec6f..2ce18f2481 100644
--- a/be/src/vec/common/assert_cast.h
+++ b/be/src/vec/common/assert_cast.h
@@ -28,7 +28,6 @@
#include "common/logging.h"
#include "fmt/format.h"
#include "vec/common/demangle.h"
-#include "vec/common/exception.h"
/** Perform static_cast in release build.
* Checks type by comparing typeid and throw an exception in debug build.
diff --git a/be/src/vec/common/exception.cpp b/be/src/vec/common/exception.cpp
deleted file mode 100644
index 6faf57ff42..0000000000
--- a/be/src/vec/common/exception.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-// This file is copied from
-//
https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/Exception.cpp
-// and modified by Doris
-
-#include "vec/common/exception.h"
-
-#include <cxxabi.h>
-#include <string.h>
-
-#include <filesystem>
-#include <iostream>
-#include <string>
-#include <type_traits>
-#include <typeinfo>
-
-namespace doris::vectorized {
-
-AbstractException::AbstractException(int code) : _pNested(0), _code(code) {}
-
-AbstractException::AbstractException(const std::string& msg, int code)
- : _msg(msg), _pNested(0), _code(code) {}
-
-AbstractException::AbstractException(const std::string& msg, const
std::string& arg, int code)
- : _msg(msg), _pNested(0), _code(code) {
- if (!arg.empty()) {
- _msg.append(": ");
- _msg.append(arg);
- }
-}
-
-AbstractException::AbstractException(const std::string& msg, const
AbstractException& nested,
- int code)
- : _msg(msg), _pNested(nested.clone()), _code(code) {}
-
-AbstractException::AbstractException(const AbstractException& exc)
- : std::exception(exc), _msg(exc._msg), _code(exc._code) {
- _pNested = exc._pNested ? exc._pNested->clone() : 0;
-}
-
-AbstractException::~AbstractException() throw() {
- delete _pNested;
-}
-
-AbstractException& AbstractException::operator=(const AbstractException& exc) {
- if (&exc != this) {
- AbstractException* newPNested = exc._pNested ? exc._pNested->clone() :
0;
- delete _pNested;
- _msg = exc._msg;
- _pNested = newPNested;
- _code = exc._code;
- }
- return *this;
-}
-
-const char* AbstractException::name() const throw() {
- return "Exception";
-}
-
-const char* AbstractException::className() const throw() {
- return typeid(*this).name();
-}
-
-const char* AbstractException::what() const throw() {
- return name();
-}
-
-std::string AbstractException::displayText() const {
- std::string txt = name();
- if (!_msg.empty()) {
- txt.append(": ");
- txt.append(_msg);
- }
- return txt;
-}
-
-void AbstractException::extendedMessage(const std::string& arg) {
- if (!arg.empty()) {
- if (!_msg.empty()) _msg.append(": ");
- _msg.append(arg);
- }
-}
-
-AbstractException* AbstractException::clone() const {
- return new AbstractException(*this);
-}
-
-void AbstractException::rethrow() const {
- throw *this;
-}
-
-//TODO: use fmt
-std::string errnoToString(int code, int e) {
- const size_t buf_size = 128;
- char buf[buf_size];
- auto result = strerror_r(e, buf, sizeof(buf));
- if constexpr (std::is_same_v<decltype(result), char*>) {
- return "errno: " + std::to_string(e) +
- ", strerror: " + std::string(reinterpret_cast<char*>(result));
- } else {
- return "errno: " + std::to_string(e) + ", strerror: " +
std::string(buf);
- }
-}
-
-void throwFromErrno(const std::string& s, int code, int e) {
- throw ErrnoException(s + ", " + errnoToString(code, e), code, e);
-}
-
-void throwFromErrnoWithPath(const std::string& s, const std::string& path, int
code,
- int the_errno) {
- throw ErrnoException(s + ", " + errnoToString(code, the_errno), code,
the_errno, path);
-}
-
-void tryLogCurrentException(const char* log_name, const std::string&
start_of_message) {
- // tryLogCurrentException(&Logger::get(log_name), start_of_message);
- std::cout << "[TODO] should use glog here :" << start_of_message <<
std::endl;
-}
-
-std::string getExtraExceptionInfo(const std::exception& e) {
- std::string msg;
- return msg;
-}
-
-std::string getCurrentExceptionMessage(bool with_stacktrace,
- bool check_embedded_stacktrace /*=
false*/,
- bool with_extra_info /*= true*/) {
- std::stringstream stream;
-
- try {
- throw;
- } catch (const Exception& e) {
- stream << getExceptionMessage(e, with_stacktrace,
check_embedded_stacktrace)
- << (with_extra_info ? getExtraExceptionInfo(e) : "") << "
(version "
- << "VERSION_STRING"
- << "VERSION_OFFICIAL"
- << ")";
- } catch (const AbstractException& e) {
- try {
- stream << "Poco::Exception. Code: " << TStatusCode::VEC_EXCEPTION
- << ", e.code() = " << e.code() << ", e.displayText() = " <<
e.displayText()
- << (with_extra_info ? getExtraExceptionInfo(e) : "") << "
(version "
- << "VERSION_STRING"
- << "VERSION_OFFICIAL";
- } catch (...) {
- }
- } catch (const std::exception& e) {
- try {
- } catch (...) {
- }
- } catch (...) {
- try {
- } catch (...) {
- }
- }
-
- return stream.str();
-}
-
-std::string getExceptionMessage(const Exception& e, bool with_stacktrace,
- bool check_embedded_stacktrace) {
- std::stringstream stream;
-
- try {
- std::string text = e.displayText();
-
- bool has_embedded_stack_trace = false;
- if (check_embedded_stacktrace) {
- auto embedded_stack_trace_pos = text.find("Stack trace");
- has_embedded_stack_trace = embedded_stack_trace_pos !=
std::string::npos;
- if (!with_stacktrace && has_embedded_stack_trace) {
- text.resize(embedded_stack_trace_pos);
- }
- }
-
- stream << "Code: " << e.code() << ", e.displayText() = " << text;
-
- if (with_stacktrace && !has_embedded_stack_trace)
- stream << ", Stack trace:\n\n" << e.getStackTrace().value();
- } catch (...) {
- }
-
- return stream.str();
-}
-
-std::string getExceptionMessage(std::exception_ptr e, bool with_stacktrace) {
- try {
- std::rethrow_exception(std::move(e));
- } catch (...) {
- return getCurrentExceptionMessage(with_stacktrace);
- }
-}
-
-} // namespace doris::vectorized
diff --git a/be/src/vec/common/exception.h b/be/src/vec/common/exception.h
deleted file mode 100644
index c30fd01c80..0000000000
--- a/be/src/vec/common/exception.h
+++ /dev/null
@@ -1,288 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-// This file is copied from
-// https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/Exception.h
-// and modified by Doris
-
-#pragma once
-
-#include <boost/exception/all.hpp>
-#include <boost/stacktrace.hpp>
-#include <cerrno>
-#include <memory>
-#include <optional>
-#include <stdexcept>
-#include <vector>
-
-#include "common/status.h"
-
-using stacktrace = boost::error_info<struct tag_stacktrace,
boost::stacktrace::stacktrace>;
-
-namespace doris::vectorized {
-
-class AbstractException : public std::exception
-/// This is the base class for all exceptions defined
-/// in the Poco class library.
-{
-public:
- AbstractException(const std::string& msg, int code = 0);
- /// Creates an exception.
-
- AbstractException(const std::string& msg, const std::string& arg, int code
= 0);
- /// Creates an exception.
-
- AbstractException(const std::string& msg, const AbstractException& nested,
int code = 0);
- /// Creates an exception and stores a clone
- /// of the nested exception.
-
- AbstractException(const AbstractException& exc);
- /// Copy constructor.
-
- ~AbstractException() throw();
- /// Destroys the exception and deletes the nested exception.
-
- AbstractException& operator=(const AbstractException& exc);
- /// Assignment operator.
-
- virtual const char* name() const throw();
- /// Returns a static string describing the exception.
-
- virtual const char* className() const throw();
- /// Returns the name of the exception class.
-
- virtual const char* what() const throw();
- /// Returns a static string describing the exception.
- ///
- /// Same as name(), but for compatibility with std::exception.
-
- const AbstractException* nested() const;
- /// Returns a pointer to the nested exception, or
- /// null if no nested exception exists.
-
- const std::string& message() const;
- /// Returns the message text.
-
- int code() const;
- /// Returns the exception code if defined.
-
- virtual std::string displayText() const;
- /// Returns a string consisting of the
- /// message name and the message text.
-
- virtual AbstractException* clone() const;
- /// Creates an exact copy of the exception.
- ///
- /// The copy can later be thrown again by
- /// invoking rethrow() on it.
-
- virtual void rethrow() const;
- /// (Re)Throws the exception.
- ///
- /// This is useful for temporarily storing a
- /// copy of an exception (see clone()), then
- /// throwing it again.
-
-protected:
- AbstractException(int code = 0);
- /// Standard constructor.
-
- void message(const std::string& msg);
- /// Sets the message for the exception.
-
- void extendedMessage(const std::string& arg);
- /// Sets the extended message for the exception.
-
-private:
- std::string _msg;
- AbstractException* _pNested;
- int _code;
-};
-
-//
-// inlines
-//
-inline const AbstractException* AbstractException::nested() const {
- return _pNested;
-}
-
-inline const std::string& AbstractException::message() const {
- return _msg;
-}
-
-inline void AbstractException::message(const std::string& msg) {
- _msg = msg;
-}
-
-inline int AbstractException::code() const {
- return _code;
-}
-
-//
-// Macros for quickly declaring and implementing exception classes.
-// Unfortunately, we cannot use a template here because character
-// pointers (which we need for specifying the exception name)
-// are not allowed as template arguments.
-//
-#define DORIS_DECLARE_EXCEPTION_CODE(API, CLS, BASE, CODE)
\
- class CLS : public BASE {
\
- public:
\
- CLS(int code = CODE);
\
- CLS(const std::string& msg, int code = CODE);
\
- CLS(const std::string& msg, const std::string& arg, int code = CODE);
\
- CLS(const std::string& msg, const AbstractException& exc, int code =
CODE); \
- CLS(const CLS& exc);
\
- ~CLS() throw();
\
- CLS& operator=(const CLS& exc);
\
- const char* name() const throw();
\
- const char* className() const throw();
\
- AbstractException* clone() const;
\
- void rethrow() const;
\
- };
-
-#define DORIS_DECLARE_EXCEPTION(API, CLS, BASE)
POCO_DECLARE_EXCEPTION_CODE(API, CLS, BASE, 0)
-
-#define DORIS_IMPLEMENT_EXCEPTION(CLS, BASE, NAME)
\
- CLS::CLS(int code) : BASE(code) {}
\
- CLS::CLS(const std::string& msg, int code) : BASE(msg, code) {}
\
- CLS::CLS(const std::string& msg, const std::string& arg, int code) :
BASE(msg, arg, code) {} \
- CLS::CLS(const std::string& msg, const AbstractException& exc, int code)
\
- : BASE(msg, exc, code) {}
\
- CLS::CLS(const CLS& exc) : BASE(exc) {}
\
- CLS::~CLS() throw() {}
\
- CLS& CLS::operator=(const CLS& exc) {
\
- BASE::operator=(exc);
\
- return *this;
\
- }
\
- const char* CLS::name() const throw() { return NAME; }
\
- const char* CLS::className() const throw() { return typeid(*this).name();
} \
- AbstractException* CLS::clone() const { return new CLS(*this); }
\
- void CLS::rethrow() const { throw *this; }
-
-class Exception : public AbstractException {
-public:
- Exception() : trace(boost::stacktrace::stacktrace()) {} /// For deferred
initialization.
- Exception(const std::string& msg, int code)
- : AbstractException(msg, code),
trace(boost::stacktrace::stacktrace()) {}
- Exception(const std::string& msg, const Exception& nested_exception, int
code)
- : AbstractException(msg, nested_exception, code),
trace(nested_exception.trace) {}
-
- enum CreateFromPocoTag { CreateFromPoco };
- Exception(CreateFromPocoTag, const AbstractException& exc)
- : AbstractException(exc.displayText(), TStatusCode::VEC_EXCEPTION),
- trace(boost::stacktrace::stacktrace()) {}
-
- Exception* clone() const override { return new Exception(*this); }
- void rethrow() const override { throw *this; }
- const char* name() const throw() override { return
"doris::vectorized::Exception"; }
- const char* what() const throw() override { return message().data(); }
-
- /// Add something to the existing message.
- void addMessage(const std::string& arg) { extendedMessage(arg); }
-
- //const StackTrace& getStackTrace() const { return trace; }
- const stacktrace& getStackTrace() const { return trace; }
-
-private:
- //StackTrace trace;
- stacktrace trace;
-
- const char* className() const throw() override { return
"doris::vectorized::Exception"; }
-};
-
-/// Contains an additional member `saved_errno`. See the throwFromErrno
function.
-class ErrnoException : public Exception {
-public:
- ErrnoException(const std::string& msg, int code, int saved_errno_,
- const std::optional<std::string>& path_ = {})
- : Exception(msg, code), saved_errno(saved_errno_), path(path_) {}
-
- ErrnoException* clone() const override { return new ErrnoException(*this);
}
- void rethrow() const override { throw *this; }
-
- int getErrno() const { return saved_errno; }
- const std::optional<std::string> getPath() const { return path; }
-
-private:
- int saved_errno;
- std::optional<std::string> path;
-
- const char* name() const throw() override { return
"doris::vectorized::ErrnoException"; }
- const char* className() const throw() override { return
"doris::vectorized::ErrnoException"; }
-};
-
-using Exceptions = std::vector<std::exception_ptr>;
-
-std::string errnoToString(int code, int the_errno = errno);
-[[noreturn]] void throwFromErrno(const std::string& s, int code, int the_errno
= errno);
-[[noreturn]] void throwFromErrnoWithPath(const std::string& s, const
std::string& path, int code,
- int the_errno = errno);
-
-/** Try to write an exception to the log (and forget about it).
- * Can be used in destructors in the catch-all block.
- */
-void tryLogCurrentException(const char* log_name, const std::string&
start_of_message = "");
-
-/** Prints current exception in canonical format.
- * with_stacktrace - prints stack trace for doris::vectorized::Exception.
- * check_embedded_stacktrace - if doris::vectorized::Exception has embedded
stacktrace then
- * only this stack trace will be printed.
- */
-std::string getCurrentExceptionMessage(bool with_stacktrace, bool
check_embedded_stacktrace = false,
- bool with_extra_info = true);
-
-int getCurrentExceptionCode();
-
-/// An execution status of any piece of code, contains return code and
optional error
-struct ExecutionStatus {
- int code = 0;
- std::string message;
-
- ExecutionStatus() = default;
-
- explicit ExecutionStatus(int return_code, const std::string&
exception_message = "")
- : code(return_code), message(exception_message) {}
-
- static ExecutionStatus fromCurrentException(const std::string&
start_of_message = "");
-
- std::string serializeText() const;
-
- void deserializeText(const std::string& data);
-
- bool tryDeserializeText(const std::string& data);
-};
-
-void tryLogException(std::exception_ptr e, const char* log_name,
- const std::string& start_of_message = "");
-
-std::string getExceptionMessage(const Exception& e, bool with_stacktrace,
- bool check_embedded_stacktrace = false);
-std::string getExceptionMessage(std::exception_ptr e, bool with_stacktrace);
-
-void rethrowFirstException(const Exceptions& exceptions);
-
-template <typename T>
-std::enable_if_t<std::is_pointer_v<T>, T> exception_cast(std::exception_ptr e)
{
- try {
- std::rethrow_exception(std::move(e));
- } catch (std::remove_pointer_t<T>& concrete) {
- return &concrete;
- } catch (...) {
- return nullptr;
- }
-}
-
-} // namespace doris::vectorized
diff --git a/be/src/vec/common/hash_table/hash_table.h
b/be/src/vec/common/hash_table/hash_table.h
index 41e7a4b446..ea4a6dda5a 100644
--- a/be/src/vec/common/hash_table/hash_table.h
+++ b/be/src/vec/common/hash_table/hash_table.h
@@ -26,9 +26,9 @@
#include <boost/noncopyable.hpp>
#include <utility>
+#include "common/exception.h"
#include "common/status.h"
#include "util/runtime_profile.h"
-#include "vec/common/exception.h"
#include "vec/common/hash_table/hash_table_allocator.h"
#include "vec/common/hash_table/hash_table_key_holder.h"
#include "vec/core/types.h"
@@ -411,8 +411,7 @@ template <typename Cell>
struct ZeroValueStorage<false, Cell> {
bool get_has_zero() const { return false; }
void set_get_has_zero() {
- throw doris::vectorized::Exception("HashTable: logical error",
-
doris::TStatusCode::VEC_LOGIC_ERROR);
+ throw doris::Exception(doris::ErrorCode::INVALID_ARGUMENT, "HashTable:
logical error");
}
void clear_get_has_zero() {}
diff --git a/be/src/vec/common/typeid_cast.h b/be/src/vec/common/typeid_cast.h
index 0284c91106..06c5004f04 100644
--- a/be/src/vec/common/typeid_cast.h
+++ b/be/src/vec/common/typeid_cast.h
@@ -25,9 +25,9 @@
#include <typeindex>
#include <typeinfo>
+#include "common/exception.h"
#include "common/status.h"
#include "vec/common/demangle.h"
-#include "vec/common/exception.h"
#define TYPEID_MAP(_A) \
template <> \
@@ -48,12 +48,12 @@ std::enable_if_t<std::is_reference_v<To>, To>
typeid_cast(From& from) {
return static_cast<To>(from);
}
} catch (const std::exception& e) {
- throw doris::vectorized::Exception(e.what(),
doris::TStatusCode::VEC_BAD_CAST);
+ throw doris::Exception(doris::ErrorCode::BAD_CAST, e.what());
}
- throw doris::vectorized::Exception("Bad cast from type " +
demangle(typeid(from).name()) +
- " to " +
demangle(typeid(To).name()),
- doris::TStatusCode::VEC_BAD_CAST);
+ throw doris::Exception(doris::ErrorCode::BAD_CAST,
+ "Bad cast from type " +
demangle(typeid(from).name()) + " to " +
+ demangle(typeid(To).name()));
}
template <typename To, typename From>
@@ -65,6 +65,6 @@ To typeid_cast(From* from) {
return nullptr;
}
} catch (const std::exception& e) {
- throw doris::vectorized::Exception(e.what(),
doris::TStatusCode::VEC_BAD_CAST);
+ throw doris::Exception(doris::ErrorCode::BAD_CAST, e.what());
}
}
diff --git a/be/src/vec/core/block.cpp b/be/src/vec/core/block.cpp
index 65d7b85e6f..aadf51946e 100644
--- a/be/src/vec/core/block.cpp
+++ b/be/src/vec/core/block.cpp
@@ -29,7 +29,6 @@
#include "runtime/descriptors.h"
#include "udf/udf.h"
#include "util/block_compression.h"
-#include "util/exception.h"
#include "util/faststring.h"
#include "util/simd/bits.h"
#include "vec/columns/column.h"
@@ -39,7 +38,6 @@
#include "vec/columns/column_vector.h"
#include "vec/columns/columns_number.h"
#include "vec/common/assert_cast.h"
-#include "vec/common/exception.h"
#include "vec/common/schema_util.h"
#include "vec/common/string_ref.h"
#include "vec/common/typeid_cast.h"
@@ -790,10 +788,8 @@ Status Block::serialize(int be_exec_version, PBlock*
pblock,
try {
column_values.resize(content_uncompressed_size);
} catch (...) {
- std::exception_ptr p = std::current_exception();
- std::string msg =
- fmt::format("Try to alloc {} bytes for pblock column values
failed. reason {}",
- content_uncompressed_size,
get_current_exception_type_name(p));
+ std::string msg = fmt::format("Try to alloc {} bytes for pblock column
values failed.",
+ content_uncompressed_size);
LOG(WARNING) << msg;
return Status::BufferAllocFailed(msg);
}
diff --git a/be/src/vec/core/field.h b/be/src/vec/core/field.h
index 00ca6d6815..685857cf90 100644
--- a/be/src/vec/core/field.h
+++ b/be/src/vec/core/field.h
@@ -26,7 +26,6 @@
#include <type_traits>
#include <vector>
-#include "vec/common/exception.h"
#include "vec/common/int_exp.h"
#include "vec/common/strong_typedef.h"
#include "vec/common/uint128.h"
diff --git a/be/src/vec/data_types/data_type_nothing.h
b/be/src/vec/data_types/data_type_nothing.h
index 15f14c6979..fd6cb8897c 100644
--- a/be/src/vec/data_types/data_type_nothing.h
+++ b/be/src/vec/data_types/data_type_nothing.h
@@ -20,8 +20,6 @@
#pragma once
-#include <vec/common/exception.h>
-
#include "vec/core/field.h"
#include "vec/data_types/data_type.h"
diff --git a/be/src/vec/io/io_helper.h b/be/src/vec/io/io_helper.h
index 59512a9e1f..c24ba2aa41 100644
--- a/be/src/vec/io/io_helper.h
+++ b/be/src/vec/io/io_helper.h
@@ -21,11 +21,11 @@
#include <iostream>
+#include "common/exception.h"
#include "gen_cpp/data.pb.h"
#include "util/binary_cast.hpp"
#include "util/string_parser.hpp"
#include "vec/common/arena.h"
-#include "vec/common/exception.h"
#include "vec/common/string_buffer.hpp"
#include "vec/common/string_ref.h"
#include "vec/common/uint128.h"
@@ -169,7 +169,7 @@ inline void read_string_binary(std::string& s,
BufferReadable& buf,
read_var_uint(size, buf);
if (size > MAX_STRING_SIZE) {
- throw Exception("Too large string size.", TStatusCode::VEC_EXCEPTION);
+ throw doris::Exception(ErrorCode::INTERNAL_ERROR, "Too large string
size.");
}
s.resize(size);
@@ -182,7 +182,7 @@ inline void read_string_binary(StringRef& s,
BufferReadable& buf,
read_var_uint(size, buf);
if (size > MAX_STRING_SIZE) {
- throw Exception("Too large string size.", TStatusCode::VEC_EXCEPTION);
+ throw doris::Exception(ErrorCode::INTERNAL_ERROR, "Too large string
size.");
}
s = buf.read(size);
@@ -211,7 +211,7 @@ void read_vector_binary(std::vector<Type>& v,
BufferReadable& buf,
read_var_uint(size, buf);
if (size > MAX_VECTOR_SIZE) {
- throw Exception("Too large vector size.", TStatusCode::VEC_EXCEPTION);
+ throw doris::Exception(ErrorCode::INTERNAL_ERROR, "Too large vector
size.");
}
v.resize(size);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]