Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::Exception Class Reference
Inheritance diagram for duckdb::Exception:
Collaboration diagram for duckdb::Exception:

Public Member Functions

DUCKDB_API Exception (ExceptionType exception_type, const string &message)
 
DUCKDB_API Exception (const unordered_map< string, string > &extra_info, ExceptionType exception_type, const string &message)
 

Static Public Member Functions

static DUCKDB_API string ExceptionTypeToString (ExceptionType type)
 
static DUCKDB_API ExceptionType StringToExceptionType (const string &type)
 
template<typename... ARGS>
static string ConstructMessage (const string &msg, ARGS const &...params)
 
static DUCKDB_API unordered_map< string, string > InitializeExtraInfo (const Expression &expr)
 
static DUCKDB_API unordered_map< string, string > InitializeExtraInfo (const ParsedExpression &expr)
 
static DUCKDB_API unordered_map< string, string > InitializeExtraInfo (const QueryErrorContext &error_context)
 
static DUCKDB_API unordered_map< string, string > InitializeExtraInfo (const TableRef &ref)
 
static DUCKDB_API unordered_map< string, string > InitializeExtraInfo (optional_idx error_location)
 
static DUCKDB_API unordered_map< string, string > InitializeExtraInfo (const string &subtype, optional_idx error_location)
 
static DUCKDB_API bool IsExecutionError (ExceptionType type)
 Whether this exception type can occur during execution of a query.
 
static DUCKDB_API string ToJSON (ExceptionType type, const string &message)
 
static DUCKDB_API string ToJSON (const unordered_map< string, string > &extra_info, ExceptionType type, const string &message)
 
static DUCKDB_API bool InvalidatesTransaction (ExceptionType exception_type)
 
static DUCKDB_API bool InvalidatesDatabase (ExceptionType exception_type)
 
static DUCKDB_API string ConstructMessageRecursive (const string &msg, std::vector< ExceptionFormatValue > &values)
 
template<class T , typename... ARGS>
static string ConstructMessageRecursive (const string &msg, std::vector< ExceptionFormatValue > &values, const T &param, ARGS &&...params)
 
static DUCKDB_API bool UncaughtException ()
 
static DUCKDB_API string GetStackTrace (idx_t max_depth=120)
 
static string FormatStackTrace (const string &message="")
 
static DUCKDB_API void SetQueryLocation (optional_idx error_location, unordered_map< string, string > &extra_info)
 

Constructor & Destructor Documentation

◆ Exception() [1/2]

duckdb::Exception::Exception ( ExceptionType  exception_type,
const string &  message 
)
70591 : std::runtime_error(ToJSON(exception_type, message)) {
70592}

◆ Exception() [2/2]

duckdb::Exception::Exception ( const unordered_map< string, string > &  extra_info,
ExceptionType  exception_type,
const string &  message 
)
70596 : std::runtime_error(ToJSON(extra_info, exception_type, message)) {
70597}

Member Function Documentation

◆ ExceptionTypeToString()

string duckdb::Exception::ExceptionTypeToString ( ExceptionType  type)
static
70729 {
70730 for (auto &e : EXCEPTION_MAP) {
70731 if (e.type == type) {
70732 return e.text;
70733 }
70734 }
70735 return "Unknown";
70736}

◆ StringToExceptionType()

ExceptionType duckdb::Exception::StringToExceptionType ( const string &  type)
static
70738 {
70739 for (auto &e : EXCEPTION_MAP) {
70740 if (e.text == type) {
70741 return e.type;
70742 }
70743 }
70744 return ExceptionType::INVALID;
70745}

◆ ConstructMessage()

template<typename... ARGS>
static string duckdb::Exception::ConstructMessage ( const string &  msg,
ARGS const &...  params 
)
inlinestatic
590 {
591 const std::size_t num_args = sizeof...(ARGS);
592 if (num_args == 0) {
593 return msg;
594 }
595 std::vector<ExceptionFormatValue> values;
596 return ConstructMessageRecursive(msg, values, params...);
597 }
PyParams params(const std::string &tag, const std::string &model, const std::string &weights, const std::string &device)

◆ InitializeExtraInfo() [1/6]

unordered_map< string, string > duckdb::Exception::InitializeExtraInfo ( const Expression expr)
static
70747 {
70748 return InitializeExtraInfo(expr.GetQueryLocation());
70749}

◆ InitializeExtraInfo() [2/6]

unordered_map< string, string > duckdb::Exception::InitializeExtraInfo ( const ParsedExpression expr)
static
70751 {
70752 return InitializeExtraInfo(expr.GetQueryLocation());
70753}

◆ InitializeExtraInfo() [3/6]

unordered_map< string, string > duckdb::Exception::InitializeExtraInfo ( const QueryErrorContext error_context)
static
70755 {
70756 return InitializeExtraInfo(error_context.query_location);
70757}

◆ InitializeExtraInfo() [4/6]

unordered_map< string, string > duckdb::Exception::InitializeExtraInfo ( const TableRef ref)
static
70759 {
70760 return InitializeExtraInfo(ref.query_location);
70761}

◆ InitializeExtraInfo() [5/6]

unordered_map< string, string > duckdb::Exception::InitializeExtraInfo ( optional_idx  error_location)
static
70763 {
70764 unordered_map<string, string> result;
70765 SetQueryLocation(error_location, result);
70766 return result;
70767}

◆ InitializeExtraInfo() [6/6]

unordered_map< string, string > duckdb::Exception::InitializeExtraInfo ( const string &  subtype,
optional_idx  error_location 
)
static
70780 {
70781 unordered_map<string, string> result;
70782 result["error_subtype"] = subtype;
70783 SetQueryLocation(error_location, result);
70784 return result;
70785}

◆ IsExecutionError()

bool duckdb::Exception::IsExecutionError ( ExceptionType  type)
static

Whether this exception type can occur during execution of a query.

70769 {
70770 switch (type) {
70771 case ExceptionType::INVALID_INPUT:
70772 case ExceptionType::OUT_OF_RANGE:
70773 case ExceptionType::CONVERSION:
70774 return true;
70775 default:
70776 return false;
70777 }
70778}

◆ ToJSON() [1/2]

string duckdb::Exception::ToJSON ( ExceptionType  type,
const string &  message 
)
static
70599 {
70600 unordered_map<string, string> extra_info;
70601 return ToJSON(extra_info, type, message);
70602}

◆ ToJSON() [2/2]

string duckdb::Exception::ToJSON ( const unordered_map< string, string > &  extra_info,
ExceptionType  type,
const string &  message 
)
static
70604 {
70605#ifndef DUCKDB_DEBUG_STACKTRACE
70606 // by default we only enable stack traces for internal exceptions
70607 if (type == ExceptionType::INTERNAL)
70608#endif
70609 {
70610 auto extended_extra_info = extra_info;
70611 // We only want to add the stack trace pointers if they are not already present, otherwise the original
70612 // stack traces are lost
70613 if (extended_extra_info.find("stack_trace_pointers") == extended_extra_info.end() &&
70614 extended_extra_info.find("stack_trace") == extended_extra_info.end()) {
70615 extended_extra_info["stack_trace_pointers"] = StackTrace::GetStacktracePointers();
70616 }
70617 return StringUtil::ExceptionToJSONMap(type, message, extended_extra_info);
70618 }
70619 return StringUtil::ExceptionToJSONMap(type, message, extra_info);
70620}
static DUCKDB_API string ExceptionToJSONMap(ExceptionType type, const string &message, const unordered_map< string, string > &map)

◆ InvalidatesTransaction()

bool duckdb::Exception::InvalidatesTransaction ( ExceptionType  exception_type)
static
70630 {
70631 switch (exception_type) {
70632 case ExceptionType::BINDER:
70633 case ExceptionType::CATALOG:
70634 case ExceptionType::CONNECTION:
70635 case ExceptionType::PARAMETER_NOT_ALLOWED:
70636 case ExceptionType::PARSER:
70637 case ExceptionType::PERMISSION:
70638 return false;
70639 default:
70640 return true;
70641 }
70642}

◆ InvalidatesDatabase()

bool duckdb::Exception::InvalidatesDatabase ( ExceptionType  exception_type)
static
70644 {
70645 switch (exception_type) {
70646 case ExceptionType::FATAL:
70647 return true;
70648 default:
70649 return false;
70650 }
70651}

◆ ConstructMessageRecursive() [1/2]

string duckdb::Exception::ConstructMessageRecursive ( const string &  msg,
std::vector< ExceptionFormatValue > &  values 
)
static
70657 {
70658#ifdef DEBUG
70659 // Verify that we have the required amount of values for the message
70660 idx_t parameter_count = 0;
70661 for (idx_t i = 0; i + 1 < msg.size(); i++) {
70662 if (msg[i] != '%') {
70663 continue;
70664 }
70665 if (msg[i + 1] == '%') {
70666 i++;
70667 continue;
70668 }
70669 parameter_count++;
70670 }
70671 if (parameter_count != values.size()) {
70672 throw InternalException("Primary exception: %s\nSecondary exception in ConstructMessageRecursive: Expected %d "
70673 "parameters, received %d",
70674 msg.c_str(), parameter_count, values.size());
70675 }
70676
70677#endif
70678 return ExceptionFormatValue::Format(msg, values);
70679}

◆ ConstructMessageRecursive() [2/2]

template<class T , typename... ARGS>
static string duckdb::Exception::ConstructMessageRecursive ( const string &  msg,
std::vector< ExceptionFormatValue > &  values,
const T &  param,
ARGS &&...  params 
)
inlinestatic
621 {
622 values.push_back(ExceptionFormatValue::CreateFormatValue<T>(param));
623 return ConstructMessageRecursive(msg, values, params...);
624 }

◆ UncaughtException()

bool duckdb::Exception::UncaughtException ( )
static
70622 {
70623#if __cplusplus >= 201703L
70624 return std::uncaught_exceptions() > 0;
70625#else
70626 return std::uncaught_exception();
70627#endif
70628}

◆ GetStackTrace()

string duckdb::Exception::GetStackTrace ( idx_t  max_depth = 120)
static
70653 {
70654 return StackTrace::GetStackTrace(max_depth);
70655}

◆ FormatStackTrace()

static string duckdb::Exception::FormatStackTrace ( const string &  message = "")
inlinestatic
629 {
630 return (message + "\n" + GetStackTrace());
631 }

◆ SetQueryLocation()

void duckdb::Exception::SetQueryLocation ( optional_idx  error_location,
unordered_map< string, string > &  extra_info 
)
static
70787 {
70788 if (error_location.IsValid()) {
70789 extra_info["position"] = to_string(error_location.GetIndex());
70790 }
70791}

The documentation for this class was generated from the following files: