exceptions.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #pragma once
6 #include <exception>
7 
8 namespace raft_proto {
9 struct bad_cuda_call : std::exception {
10  bad_cuda_call() : bad_cuda_call("CUDA API call failed") {}
11  bad_cuda_call(char const* msg) : msg_{msg} {}
12  virtual char const* what() const noexcept { return msg_; }
13 
14  private:
15  char const* msg_;
16 };
17 
18 struct out_of_bounds : std::exception {
19  out_of_bounds() : out_of_bounds("Attempted out-of-bounds memory access") {}
20  out_of_bounds(char const* msg) : msg_{msg} {}
21  virtual char const* what() const noexcept { return msg_; }
22 
23  private:
24  char const* msg_;
25 };
26 
27 struct wrong_device_type : std::exception {
28  wrong_device_type() : wrong_device_type("Attempted to use host data on GPU or device data on CPU")
29  {
30  }
31  wrong_device_type(char const* msg) : msg_{msg} {}
32  virtual char const* what() const noexcept { return msg_; }
33 
34  private:
35  char const* msg_;
36 };
37 
38 struct mem_type_mismatch : std::exception {
39  mem_type_mismatch() : mem_type_mismatch("Memory type does not match expected type") {}
40  mem_type_mismatch(char const* msg) : msg_{msg} {}
41  virtual char const* what() const noexcept { return msg_; }
42 
43  private:
44  char const* msg_;
45 };
46 
47 struct wrong_device : std::exception {
48  wrong_device() : wrong_device("Attempted to use incorrect device") {}
49  wrong_device(char const* msg) : msg_{msg} {}
50  virtual char const* what() const noexcept { return msg_; }
51 
52  private:
53  char const* msg_;
54 };
55 
56 } // namespace raft_proto
Definition: buffer.hpp:24
Definition: exceptions.hpp:9
virtual char const * what() const noexcept
Definition: exceptions.hpp:12
bad_cuda_call(char const *msg)
Definition: exceptions.hpp:11
bad_cuda_call()
Definition: exceptions.hpp:10
Definition: exceptions.hpp:38
mem_type_mismatch(char const *msg)
Definition: exceptions.hpp:40
mem_type_mismatch()
Definition: exceptions.hpp:39
virtual char const * what() const noexcept
Definition: exceptions.hpp:41
Definition: exceptions.hpp:18
out_of_bounds(char const *msg)
Definition: exceptions.hpp:20
out_of_bounds()
Definition: exceptions.hpp:19
virtual char const * what() const noexcept
Definition: exceptions.hpp:21
Definition: exceptions.hpp:27
wrong_device_type()
Definition: exceptions.hpp:28
virtual char const * what() const noexcept
Definition: exceptions.hpp:32
wrong_device_type(char const *msg)
Definition: exceptions.hpp:31
Definition: exceptions.hpp:47
virtual char const * what() const noexcept
Definition: exceptions.hpp:50
wrong_device()
Definition: exceptions.hpp:48
wrong_device(char const *msg)
Definition: exceptions.hpp:49