5#ifndef TABLEAU_HYPER_HYPEREXCEPTION_HPP
6#define TABLEAU_HYPER_HYPEREXCEPTION_HPP
8#include <hyperapi/impl/infra.hpp>
10#include <hyperapi/hyperapi.h>
24 const uint32_t value_;
27 constexpr explicit ContextId(uint32_t value) noexcept
30 constexpr uint32_t getValue()
const noexcept {
return value_; }
54 const char*
getMainMessage() const noexcept {
return getStringField(HYPER_ERROR_FIELD_MESSAGE); }
59 const char*
getHint() const noexcept {
return getStringField(HYPER_ERROR_FIELD_HINT_MESSAGE); }
66 HYPER_DEPRECATED(
"Use getMainMessage() instead. This function will be removed in the future.")
68 getMessage() const noexcept {
77 HYPER_DEPRECATED(
"Use getHint() instead. This function will be removed in the future.")
79 getHintMessage() const noexcept {
88 HYPER_DEPRECATED(
"Use getCause().has_value() instead. This function will be removed in the future.")
89 bool hasCause() const noexcept {
return (getCauseHandle() !=
nullptr); }
109 const char*
what() const noexcept override;
128 explicit
HyperException(hyper_error_t* error, std::shared_ptr<const hyper_error_t> top_level_error);
135 const
char* getStringField(hyper_error_field_key key) const noexcept;
142 int getIntField(hyper_error_field_key key) const noexcept;
149 uint32_t getUIntField(hyper_error_field_key key) const noexcept;
154 hyper_error_t* getCauseHandle() const noexcept;
157 std::shared_ptr<const hyper_error_t> error_;
160 mutable std::
string stringRepresentation_;
169 friend
HyperException internal::makeHyperException(hyper_error_t*);
170 friend class HyperExceptionTest;
174#include <hyperapi/impl/HyperException.impl.hpp>
Defines an exception object that is thrown on failure by the functions in the Hyper API C++ library.
HYPER_DEPRECATED("Use getMainMessage() instead. This function will be removed in the future.") const char *getMessage() const noexcept
Returns the message stored in the exception object, or "" if there is none.
HYPER_DEPRECATED("Use getCause().has_value() instead. This function will be removed in the future.") bool hasCause() const noexcept
Returns whether this error has an underlying cause stored.
HYPER_DEPRECATED("Use getHint() instead. This function will be removed in the future.") const char *getHintMessage() const noexcept
Returns the hint message stored in the exception object, or "" if there is none.
const char * getMainMessage() const noexcept
Returns the message stored in the exception object, or "" if there is none.
ContextId getContextId() const noexcept
Returns the context id.
optional< HyperException > getCause() const noexcept
Returns the cause stored in the exception object.
HyperException(const HyperException &other) noexcept
Copy constructor.
HyperException & operator=(const HyperException &other) noexcept
Copy assignment operator.
const char * what() const noexcept override
Returns a null terminated character sequence that may be used to identify the exception.
HyperException & operator=(HyperException &&other)=default
Move assignment operator.
const char * getHint() const noexcept
Returns the hint message stored in the exception object, or "" if there is none.
std::string toString() const
Returns a formatted string containing the message and hint of the error and all causes.
HyperException(HyperException &&other)=default
Move constructor.
Surrogate for C++17 std::optional
The primary namespace of the Hyper API for C++.