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::ErrorManager Class Reference

Public Member Functions

template<typename... ARGS>
string FormatException (ErrorType error_type, ARGS &&...params)
DUCKDB_API string FormatExceptionRecursive (ErrorType error_type, vector< ExceptionFormatValue > &values)
template<class T, typename... ARGS>
string FormatExceptionRecursive (ErrorType error_type, vector< ExceptionFormatValue > &values, T param, ARGS &&...params)
void AddCustomError (ErrorType type, string new_error)
 Adds a custom error for a specific error type.

Static Public Member Functions

template<typename... ARGS>
static string FormatException (ClientContext &context, ErrorType error_type, ARGS &&...params)
static DUCKDB_API InvalidInputException InvalidUnicodeError (const String &input, const string &context)
static DUCKDB_API FatalException InvalidatedDatabase (ClientContext &context, const string &invalidated_msg)
static DUCKDB_API TransactionException InvalidatedTransaction (ClientContext &context)
static DUCKDB_API ErrorManager & Get (ClientContext &context)
static DUCKDB_API ErrorManager & Get (DatabaseInstance &context)

Private Attributes

map< ErrorType, string > custom_errors

Detailed Description

The error manager class is responsible for formatting error messages It allows for error messages to be overridden by extensions and clients

Member Function Documentation

◆ FormatException() [1/2]

template<typename... ARGS>
string duckdb::ErrorManager::FormatException ( ErrorType error_type,
ARGS &&... params )
inline
60299 {
60300 vector<ExceptionFormatValue> values;
60301 return FormatExceptionRecursive(error_type, values, std::forward<ARGS>(params)...);
60302 }

◆ FormatExceptionRecursive() [1/2]

string duckdb::ErrorManager::FormatExceptionRecursive ( ErrorType error_type,
vector< ExceptionFormatValue > & values )
278155 {
278156 if (error_type >= ErrorType::ERROR_COUNT) {
278157 throw InternalException("Invalid error type passed to ErrorManager::FormatError");
278158 }
278159 auto entry = custom_errors.find(error_type);
278160 string error;
278161 if (entry != custom_errors.end()) {
278162 // Error was overwritten.
278163 error = entry->second;
278164 return ExceptionFormatValue::Format(error, values);
278165 }
278166
278167 // Error was not overwritten.
278168 error = internal_errors[int(error_type)].error;
278169
278170 if (error_type != ErrorType::INVALIDATED_DATABASE) {
278171 return ExceptionFormatValue::Format(error, values);
278172 }
278173
278174 for (const auto &val : values) {
278175 if (StringUtil::Contains(val.str_val, error)) {
278176 error = "%s";
278177 return ExceptionFormatValue::Format(error, values);
278178 }
278179 }
278180 error += "Original error: \"%s\"";
278181 return ExceptionFormatValue::Format(error, values);
278182}
static DUCKDB_API bool Contains(const string &haystack, const string &needle)
Returns true if the needle string exists in the haystack.
Definition duckdb.cpp:109323

◆ FormatExceptionRecursive() [2/2]

template<class T, typename... ARGS>
string duckdb::ErrorManager::FormatExceptionRecursive ( ErrorType error_type,
vector< ExceptionFormatValue > & values,
T param,
ARGS &&... params )
inline
60308 {
60309 values.push_back(ExceptionFormatValue::CreateFormatValue<T>(param));
60310 return FormatExceptionRecursive(error_type, values, std::forward<ARGS>(params)...);
60311 }

◆ FormatException() [2/2]

template<typename... ARGS>
string duckdb::ErrorManager::FormatException ( ClientContext & context,
ErrorType error_type,
ARGS &&... params )
inlinestatic
60314 {
60315 return Get(context).FormatException(error_type, std::forward<ARGS>(params)...);
60316 }

◆ InvalidUnicodeError()

InvalidInputException duckdb::ErrorManager::InvalidUnicodeError ( const String & input,
const string & context )
static
278184 {
278185 UnicodeInvalidReason reason;
278186 size_t pos;
278187 auto unicode = Utf8Proc::Analyze(const_char_ptr_cast(input.c_str()), input.size(), &reason, &pos);
278188 if (unicode != UnicodeType::INVALID) {
278189 return InvalidInputException("Invalid unicode error thrown but no invalid unicode detected in " + context);
278190 }
278191 string base_message;
278192 switch (reason) {
278193 case UnicodeInvalidReason::BYTE_MISMATCH:
278194 base_message = "Invalid unicode (byte sequence mismatch)";
278195 break;
278196 case UnicodeInvalidReason::INVALID_UNICODE:
278197 base_message = "Invalid unicode";
278198 break;
278199 default:
278200 break;
278201 }
278202 return InvalidInputException(base_message + " detected in " + context);
278203}
static UnicodeType Analyze(const char *s, size_t len, UnicodeInvalidReason *invalid_reason=nullptr, size_t *invalid_pos=nullptr)
Distinguishes ASCII, Valid UTF8 and Invalid UTF8 strings.
Definition duckdb.cpp:507297

◆ InvalidatedDatabase()

FatalException duckdb::ErrorManager::InvalidatedDatabase ( ClientContext & context,
const string & invalidated_msg )
static
278205 {
278206 return FatalException(ErrorManager::FormatException(context, ErrorType::INVALIDATED_DATABASE, invalidated_msg));
278207}

◆ InvalidatedTransaction()

TransactionException duckdb::ErrorManager::InvalidatedTransaction ( ClientContext & context)
static
278209 {
278210 return TransactionException(ErrorManager::FormatException(context, ErrorType::INVALIDATED_TRANSACTION));
278211}

◆ AddCustomError()

void duckdb::ErrorManager::AddCustomError ( ErrorType type,
string new_error )

Adds a custom error for a specific error type.

278213 {
278214 custom_errors.insert(make_pair(type, std::move(new_error)));
278215}

◆ Get() [1/2]

ErrorManager & duckdb::ErrorManager::Get ( ClientContext & context)
static
278217 {
278218 return *DBConfig::GetConfig(context).error_manager;
278219}

◆ Get() [2/2]

ErrorManager & duckdb::ErrorManager::Get ( DatabaseInstance & context)
static
278221 {
278222 return *DBConfig::GetConfig(context).error_manager;
278223}

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