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

llnl-asr / dftracer-utils / 36502607218

29 Sep 2026 12:20AM UTC coverage: 57.996% (+5.4%) from 52.58%
36502607218

push

github

rayandrew
Merge branch 'feat/view-as-lazyframe' into 'develop'

feat: view as lazyframe

See merge request dftracer/dftracer-utils!25

74077 of 162805 branches covered (45.5%)

Branch coverage included in aggregate %.

3652 of 3978 new or added lines in 49 files covered. (91.8%)

3464 existing lines in 85 files now uncovered.

65902 of 78556 relevant lines covered (83.89%)

179668.29 hits per line

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

63.36
/src/dftracer/utils/python/py_errors.cpp
1
#include <dftracer/utils/python/py_errors.h>
2
#include <dftracer/utils/query/errc.h>
3

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

7
namespace dftracer::utils::python {
8

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

21
using dftracer::utils::ErrorCode;
22

23
namespace {
24

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

43
}  // namespace
44

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

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

105
PyObject *py_error_type_for(const dftracer::utils::DFTUtilsException &e) {
18 ✔
106
    // Domain-specific types take precedence over the portable-condition map.
107
    if (e.domain() == dftracer::utils::query::ERROR_DOMAIN.id)
18 ✔
108
        return g_dft_query_error;
2 ✔
109
    return py_error_type_for(e.code());
16 ✔
110
}
9 ✔
111

112
void set_typed_py_error(const std::exception &e) {
12 ✔
113
    if (const auto *de =
12 !
114
            dynamic_cast<const dftracer::utils::DFTUtilsException *>(&e)) {
12 !
115
        PyErr_SetString(py_error_type_for(*de), e.what());
12 ✔
116
    } else if (dynamic_cast<const std::invalid_argument *>(&e)) {
6 !
UNCOV
117
        PyErr_SetString(g_dft_value_error, e.what());
×
118
    } else {
UNCOV
119
        PyErr_SetString(g_dft_error, e.what());
×
120
    }
121
}
12 ✔
122

123
}  // namespace dftracer::utils::python
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