error.hpp
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 #include <rmm/detail/export.hpp>
9 
10 #include <stdexcept>
11 #include <string>
12 
13 namespace RMM_NAMESPACE {
14 
24 struct logic_error : public std::logic_error {
25  using std::logic_error::logic_error;
26 };
27 
34 struct cuda_error : public std::runtime_error {
35  using std::runtime_error::runtime_error;
36 };
37 
44 class bad_alloc : public std::bad_alloc {
45  public:
51  bad_alloc(const char* msg);
52 
58  bad_alloc(std::string const& msg);
59 
63  [[nodiscard]] const char* what() const noexcept override;
64 
65  private:
66  std::string _what;
67 };
68 
76 class out_of_memory : public bad_alloc {
77  public:
83  out_of_memory(const char* msg);
84 
90  out_of_memory(std::string const& msg);
91 };
92 
99 class out_of_range : public std::out_of_range {
100  using std::out_of_range::out_of_range;
101 };
102 
103 } // namespace RMM_NAMESPACE
Exception thrown when an RMM allocation fails.
Definition: error.hpp:44
const char * what() const noexcept override
The explanatory string.
bad_alloc(std::string const &msg)
Constructs a bad_alloc with the error message.
bad_alloc(const char *msg)
Constructs a bad_alloc with the error message.
Exception thrown when RMM runs out of memory.
Definition: error.hpp:76
out_of_memory(std::string const &msg)
Constructs an out_of_memory with the error message.
out_of_memory(const char *msg)
Constructs an out_of_memory with the error message.
Exception thrown when attempting to access outside of a defined range.
Definition: error.hpp:99
Exception thrown when a CUDA error is encountered.
Definition: error.hpp:34
Exception thrown when logical precondition is violated.
Definition: error.hpp:24