raiigraph
C++ RAII for igraph data structures
Loading...
Searching...
No Matches
error.hpp
Go to the documentation of this file.
1#ifndef RAIIGRAPH_ERROR_HPP
2#define RAIIGRAPH_ERROR_HPP
3
4#include "igraph.h"
5
11namespace raiigraph {
12
16class IgraphError : public std::runtime_error {
17public:
21 IgraphError(igraph_error_t code) : std::runtime_error(igraph_strerror(code)), my_code(code) {}
22
27 igraph_error_t code() const {
28 return my_code;
29 }
30
31private:
32 igraph_error_t my_code;
33};
34
39inline void check_code(igraph_error_t code) {
40 if (code != IGRAPH_SUCCESS) {
41 throw IgraphError(code);
42 }
43}
44
45}
46
47#endif
Error class for igraph-related errors.
Definition error.hpp:16
IgraphError(igraph_error_t code)
Definition error.hpp:21
igraph_error_t code() const
Definition error.hpp:27
Utilities for manipulating igraph data structures in C++.
Definition error.hpp:11
void check_code(igraph_error_t code)
Definition error.hpp:39