• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

llnl / dftracer-utils / 30067416336

24 Jul 2026 04:40AM UTC coverage: 50.693% (-2.0%) from 52.66%
30067416336

Pull #99

github

web-flow
Merge 464586f0d into 06bc84ec9
Pull Request #99: Support CM time_metric (NS/MS/SEC/US) across reader and viz

18063 of 48203 branches covered (37.47%)

Branch coverage included in aggregate %.

1514 of 2204 new or added lines in 58 files covered. (68.69%)

741 existing lines in 114 files now uncovered.

23715 of 34210 relevant lines covered (69.32%)

39842.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

43.55
/src/dftracer/utils/python/py_errors.cpp
1
#include <dftracer/utils/python/py_errors.h>
2

3
#include <stdexcept>
4
#include <string>
5

6
PyObject *g_dft_error = nullptr;
7
PyObject *g_dft_value_error = nullptr;
8
PyObject *g_dft_not_found_error = nullptr;
9
PyObject *g_dft_io_error = nullptr;
10
PyObject *g_dft_parse_error = nullptr;
11
PyObject *g_dft_compression_error = nullptr;
12
PyObject *g_dft_query_error = nullptr;
13
PyObject *g_dft_reader_error = nullptr;
14
PyObject *g_dft_indexer_error = nullptr;
15
PyObject *g_dft_pipeline_error = nullptr;
16
PyObject *g_dft_aggregation_error = nullptr;
17

18
using dftracer::utils::ErrorCode;
19

20
namespace {
21

22
// Create exception "dftracer_utils_ext.<short_name>", register it on m, and
23
// keep a strong ref in *slot.
24
int add_exc(PyObject *m, const char *short_name, PyObject *base,
11✔
25
            PyObject **slot) {
26
    const std::string qualified =
27
        std::string("dftracer_utils_ext.") + short_name;
22!
28
    PyObject *exc = PyErr_NewException(qualified.c_str(), base, nullptr);
11!
29
    if (exc == nullptr) return -1;
11!
30
    Py_INCREF(exc);  // keep one strong ref in *slot in addition to the module's
31
    if (PyModule_AddObject(m, short_name, exc) < 0) {
11!
32
        Py_DECREF(exc);  // undo AddObject's intended steal
33
        Py_DECREF(exc);  // undo our INCREF
34
        return -1;
×
35
    }
36
    *slot = exc;
11✔
37
    return 0;
11✔
38
}
11✔
39

40
}  // namespace
41

42
int init_py_errors(PyObject *m) {
1✔
43
    if (add_exc(m, "DFTUtilsError", PyExc_RuntimeError, &g_dft_error) < 0)
1!
44
        return -1;
×
45
    if (add_exc(m, "DFTUtilsValueError", g_dft_error, &g_dft_value_error) < 0)
1!
46
        return -1;
×
47
    if (add_exc(m, "DFTUtilsNotFoundError", g_dft_error,
1✔
48
                &g_dft_not_found_error) < 0)
1!
49
        return -1;
×
50
    if (add_exc(m, "DFTUtilsIOError", g_dft_error, &g_dft_io_error) < 0)
1!
51
        return -1;
×
52
    if (add_exc(m, "DFTUtilsParseError", g_dft_error, &g_dft_parse_error) < 0)
1!
53
        return -1;
×
54
    if (add_exc(m, "DFTUtilsCompressionError", g_dft_error,
1✔
55
                &g_dft_compression_error) < 0)
1!
56
        return -1;
×
57
    if (add_exc(m, "DFTUtilsQueryError", g_dft_error, &g_dft_query_error) < 0)
1!
58
        return -1;
×
59
    if (add_exc(m, "DFTUtilsReaderError", g_dft_error, &g_dft_reader_error) < 0)
1!
60
        return -1;
×
61
    if (add_exc(m, "DFTUtilsIndexerError", g_dft_error, &g_dft_indexer_error) <
1!
62
        0)
63
        return -1;
×
64
    if (add_exc(m, "DFTUtilsPipelineError", g_dft_error,
1✔
65
                &g_dft_pipeline_error) < 0)
1!
66
        return -1;
×
67
    if (add_exc(m, "DFTUtilsAggregationError", g_dft_error,
1✔
68
                &g_dft_aggregation_error) < 0)
1!
69
        return -1;
×
70
    return 0;
1✔
71
}
72

73
PyObject *py_error_type_for(ErrorCode code) {
1✔
74
    switch (code) {
1!
UNCOV
75
        case ErrorCode::INVALID_ARGUMENT:
×
76
            return g_dft_value_error;
×
UNCOV
77
        case ErrorCode::NOT_FOUND:
×
78
            return g_dft_not_found_error;
×
79
        case ErrorCode::IO:
1✔
80
            return g_dft_io_error;
1✔
UNCOV
81
        case ErrorCode::PARSE:
×
82
            return g_dft_parse_error;
×
UNCOV
83
        case ErrorCode::COMPRESSION:
×
84
            return g_dft_compression_error;
×
UNCOV
85
        case ErrorCode::QUERY:
×
86
            return g_dft_query_error;
×
UNCOV
87
        case ErrorCode::READER:
×
88
            return g_dft_reader_error;
×
UNCOV
89
        case ErrorCode::INDEXER:
×
90
            return g_dft_indexer_error;
×
UNCOV
91
        case ErrorCode::PIPELINE:
×
92
            return g_dft_pipeline_error;
×
UNCOV
93
        case ErrorCode::AGGREGATION:
×
94
            return g_dft_aggregation_error;
×
UNCOV
95
        case ErrorCode::UNKNOWN:
×
96
        case ErrorCode::INTERNAL:
97
            return g_dft_error;
×
98
    }
99
    return g_dft_error;
×
100
}
101

102
void set_typed_py_error(const std::exception &e) {
1✔
103
    if (const auto *de =
1!
104
            dynamic_cast<const dftracer::utils::DFTUtilsException *>(&e)) {
1!
105
        PyErr_SetString(py_error_type_for(de->code()), e.what());
1✔
UNCOV
106
    } else if (dynamic_cast<const std::invalid_argument *>(&e)) {
×
107
        PyErr_SetString(g_dft_value_error, e.what());
×
108
    } else {
109
        PyErr_SetString(g_dft_error, e.what());
×
110
    }
111
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc