Error Handling#

2026-03-13

4 min read time

Applies to Linux

Exceptions#

#include <raft/core/error.hpp>

namespace raft

struct cublas_error : public raft::exception#
#include <cublas_macros.hpp>

Exception thrown when a cuBLAS error is encountered.

struct cusolver_error : public raft::exception#
#include <cusolver_macros.hpp>

Exception thrown when a cuSOLVER error is encountered.

struct cusparse_error : public raft::exception#
#include <cusparse_macros.hpp>

Exception thrown when a cuSparse error is encountered.

class exception : public std::exception#
#include <error.hpp>

base exception class for the whole of raft

Subclassed by raft::cublas_error, raft::cuda_error, raft::cusolver_error, raft::cusparse_error, raft::cutlass_error, raft::interrupted_exception, raft::logic_error, raft::non_cuda_build_error

Public Functions

inline explicit exception(
) noexcept#

default ctor

inline exception(
exception const &src
) noexcept#

copy ctor

inline explicit exception(
std::string const msg
) noexcept#

ctor from an input message

inline char const *what(
) const noexcept override#

get the message associated with this exception

struct logic_error : public raft::exception#
#include <error.hpp>

Exception thrown when logical precondition is violated.

This exception should not be thrown directly and is instead thrown by the RAFT_EXPECTS and RAFT_FAIL macros.

struct non_cuda_build_error : public raft::exception#
#include <error.hpp>

Exception thrown when attempting to use CUDA features from a non-CUDA build.

Assertion Macros#

#include <raft/core/error.hpp>

RAFT_CUSOLVER_TRY(call)#

Error checking macro for cuSOLVER runtime API functions.

Invokes a cuSOLVER runtime API function call, if the call does not return CUSolver_STATUS_SUCCESS, throws an exception detailing the cuSOLVER error that occurred

CUSOLVER_TRY(call)#

Error checking macro for cuSOLVER runtime API functions.

Invokes a cuSOLVER runtime API function call, if the call does not return CUSolver_STATUS_SUCCESS, throws an exception detailing the cuSOLVER error that occurred

RAFT_CUSOLVER_TRY_NO_THROW(call)#

Error checking macro for cuSOLVER runtime API functions.

Invokes a cuSOLVER runtime API function call, if the call does not return CUSolver_STATUS_SUCCESS, throws an exception detailing the cuSOLVER error that occurred

RAFT_CUSPARSE_TRY(call)#

Error checking macro for cuSparse runtime API functions.

Invokes a cuSparse runtime API function call, if the call does not return CUSPARSE_STATUS_SUCCESS, throws an exception detailing the cuSparse error that occurred

RAFT_CUSPARSE_TRY_NO_THROW(call)#

check for cusparse runtime API errors but do not assert

RAFT_CUBLAS_TRY(call)#

Error checking macro for cuBLAS runtime API functions.

Invokes a cuBLAS runtime API function call, if the call does not return CUBLAS_STATUS_SUCCESS, throws an exception detailing the cuBLAS error that occurred

CUBLAS_TRY(call)#
RAFT_CUBLAS_TRY_NO_THROW(call)#
RAFT_EXPECTS(cond, fmt, ...)#

Macro for checking (pre-)conditions that throws an exception when a condition is false.

Parameters:
  • cond[in] Expression that evaluates to true or false

  • fmt[in] String literal description of the reason that cond is expected to be true with optional format tagas

Throws raft::logic_error:

if the condition evaluates to false.

RAFT_FAIL(fmt, ...)#

Indicates that an erroneous code path has been taken.

Parameters:
  • fmt[in] String literal description of the reason that this code path is erroneous with optional format tagas

Throws always:

throws raft::logic_error