Coverage Report

Created: 2023-06-07 06:59

/src/valijson/include/valijson/exceptions.hpp
Line
Count
Source (jump to first uncovered line)
1
#pragma once
2
3
#include <iostream>
4
#include <exception>
5
6
namespace valijson {
7
#if defined(_MSC_VER) && _MSC_VER == 1800
8
#define VALIJSON_NORETURN __declspec(noreturn)
9
#else
10
#define VALIJSON_NORETURN [[noreturn]]
11
#endif
12
13
#if VALIJSON_USE_EXCEPTIONS
14
#include <stdexcept>
15
16
103
VALIJSON_NORETURN inline void throwRuntimeError(const std::string& msg) {
17
103
  throw std::runtime_error(msg);
18
103
}
19
20
0
VALIJSON_NORETURN inline void throwLogicError(const std::string& msg) {
21
0
  throw std::logic_error(msg);
22
0
}
23
#else
24
VALIJSON_NORETURN inline void throwRuntimeError(const std::string& msg) {
25
  std::cerr << msg << std::endl;
26
  abort();
27
}
28
VALIJSON_NORETURN inline void throwLogicError(const std::string& msg) {
29
  std::cerr << msg << std::endl;
30
  abort();
31
}
32
33
#endif
34
35
0
VALIJSON_NORETURN inline void throwNotSupported() {
36
0
    throwRuntimeError("Not supported");
37
0
}
38
39
} // namespace valijson