Utility Error#
- group Exception
Defines
-
CUDF_EXPECTS(...)#
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
Defaults to throwing
cudf::logic_error, but a custom exception may also be specified.Example usage:
// throws cudf::logic_error CUDF_EXPECTS(p != nullptr, "Unexpected null pointer"); // throws std::runtime_error CUDF_EXPECTS(p != nullptr, "Unexpected nullptr", std::runtime_error);
- Parameters:
... – This macro accepts either two or three arguments:
The first argument must be an expression that evaluates to true or false, and is the condition being checked.
The second argument is an expression that produces the error message used to construct the
whatof the exception. This can be a string literal or a dynamic expression (e.g.,std::to_string(x) + " is invalid"). The expression is only evaluated when the condition fails.When given, the third argument is the exception to be thrown. When not specified, defaults to
cudf::logic_error.
- Throws `_exception_type`:
if the condition evaluates to 0 (false).
-
CUDF_FAIL(...)#
Indicates that an erroneous code path has been taken.
Example usage:
// Throws `cudf::logic_error` CUDF_FAIL("Unsupported code path"); // Throws `std::runtime_error` CUDF_FAIL("Unsupported code path", std::runtime_error);
- Parameters:
... – This macro accepts either one or two arguments:
The first argument is an expression that produces the error message used to construct the
whatof the exception. This can be a string literal or a dynamic expression (e.g.,std::to_string(x) + " is invalid").When given, the second argument is the exception to be thrown. When not specified, defaults to
cudf::logic_error.
- Throws `_exception_type`:
if the condition evaluates to 0 (false).
-
CUDF_CUDA_TRY(call)#
Error checking macro for CUDA runtime API functions.
Invokes a CUDA runtime API function call, if the call does not return cudaSuccess, invokes cudaGetLastError() to clear the error and throws an exception detailing the CUDA error that occurred
-
CUDF_CHECK_CUDA(stream)#
Debug macro to check for CUDA errors.
In a non-release build, this macro will synchronize the specified stream before error checking. In both release and non-release builds, this macro checks for any pending CUDA errors from previous calls. If an error is reported, an exception is thrown detailing the CUDA error that occurred.
The intent of this macro is to provide a mechanism for synchronous and deterministic execution for debugging asynchronous CUDA execution. It should be used after any asynchronous CUDA call, e.g., cudaMemcpyAsync, or an asynchronous kernel launch.
Typedefs
-
using error_int = int32_t#
Integer representation of error codes, compatible with external consumers such as Numba.
Enums
-
enum class errc : error_int#
Operation error codes. Zero means success. User-defined errors must be in [USER_RESERVED_BEGIN, USER_RESERVED_END). Other values are reserved for libcudf.
Note
error codes are ordered by severity, with lower values indicating more severe errors.
Values:
-
enumerator SUCCESS#
-
enumerator DIVISION_BY_ZERO#
-
enumerator ARITHMETIC_OVERFLOW#
-
enumerator USER_RESERVED_BEGIN#
-
enumerator USER_RESERVED_END#
-
enumerator SUCCESS#
Functions
-
struct logic_error : public std::logic_error#
- #include <cudf/utilities/error.hpp>
Exception thrown when logical precondition is violated.
This exception should not be thrown directly and is instead thrown by the CUDF_EXPECTS macro.
Public Functions
-
inline explicit logic_error(char const *const message)#
Constructs a logic_error with the error message.
- Parameters:
message – Message to be associated with the exception
-
inline explicit logic_error(std::string const &message)#
Construct a new logic error object with error message.
- Parameters:
message – Message to be associated with the exception
-
inline ~logic_error() override#
Destroy the logic error object.
-
inline explicit logic_error(char const *const message)#
-
struct cuda_error : public std::runtime_error#
- #include <cudf/utilities/error.hpp>
Exception thrown when a CUDA error is encountered.
Subclassed by cudf::fatal_cuda_error
Public Functions
- inline explicit cuda_error(
- std::string const &message,
- cudaError_t const &error
Construct a new cuda error object with error message and code.
- Parameters:
message – Error message
error – CUDA error code
-
inline cudaError_t error_code() const#
Returns the CUDA error code associated with the exception.
- Returns:
CUDA error code
-
struct fatal_cuda_error : public cudf::cuda_error#
Public Functions
- inline explicit cuda_error(
- std::string const &message,
- cudaError_t const &error
Construct a new cuda error object with error message and code.
- Parameters:
message – Error message
error – CUDA error code
-
struct data_type_error : public std::invalid_argument#
- #include <cudf/utilities/error.hpp>
Exception thrown when an operation is attempted on an unsupported dtype.
This exception should be thrown when an operation is attempted on an unsupported data_type. This exception should not be thrown directly and is instead thrown by the CUDF_EXPECTS or CUDF_FAIL macros.
Public Functions
-
inline explicit data_type_error(char const *const message)#
Constructs a data_type_error with the error message.
- Parameters:
message – Message to be associated with the exception
-
inline explicit data_type_error(std::string const &message)#
Construct a new data_type_error object with error message.
- Parameters:
message – Message to be associated with the exception
-
inline explicit data_type_error(char const *const message)#
-
struct evaluation_error : public std::exception#
- #include <cudf/utilities/evaluation_error.hpp>
An evaluation failure and the row and operator that produced it.
Row and operator context is disengaged when unavailable.
Public Functions
-
inline evaluation_error(errc error, std::string message)#
Constructs an error without row or operator context.
- Parameters:
error – Evaluation status
message – Diagnostic message
- inline evaluation_error(
- errc error,
- std::optional<size_type> row_index,
- std::optional<std::string> op_name,
- std::optional<ast::jit::op> op,
- std::string message,
- std::optional<int32_t> expression_id = std::nullopt
Constructs an error with execution context.
- Parameters:
error – Evaluation status
row_index – Logical input row, or left row for a join; nullopt if unavailable
op_name – Operator name or UDF symbol, nullopt if unavailable
op – Built-in JIT operator, nullopt for UDF calls or unavailable context
message – Diagnostic message
expression_id – Caller-provided ID of the failing expression, nullopt if unavailable
-
inline char const *what() const noexcept override#
Returns the diagnostic message.
- Returns:
Message with the available context
-
inline errc error_code() const noexcept#
Returns the evaluation status.
- Returns:
Error code, including user-defined codes
-
inline std::optional<size_type> row_index() const noexcept#
Returns the logical input row, or the left row for a join filter.
- Returns:
Row index, or std::nullopt if unavailable
-
inline std::optional<std::string> const &op_name() const noexcept#
Returns the operator name or UDF symbol.
- Returns:
Name, or std::nullopt if unavailable
-
inline std::optional<ast::jit::op> op() const noexcept#
Returns the built-in JIT operator.
- Returns:
Operator, or std::nullopt for UDF calls or unavailable context
-
inline std::optional<int32_t> expression_id() const noexcept#
Returns the caller-provided ID of the failing expression.
- Returns:
Identifier, or std::nullopt if none was assigned or expression context is unavailable
-
inline evaluation_error(errc error, std::string message)#
-
CUDF_EXPECTS(...)#