Add basic exception handling
Consider a dot literal:
dot"""
graph G{
a -> b
}
"""
Currently this will give an assertion exception when layout discovers the graph.handle is C_NULL. Actually Graphviz is confused that there is a -> and it's not a digraph.
This PR handles null return values from the cgraph functions immediately and converts them into Julia exceptions. Unfortunately this does not give very good error messages (the actual error message is still just printed to stderr), however it's a bit better than the current situation, which is even less since nice in Pluto.jl since stderr is currently not routed to the Notebook by default.
I made an attempt to try and capture the error message in jl_putstr and jlio_write so that it could be put onto the exception, but this did not work out. For some reason Graphviz is not routing the error messages through these callbacks.
Codecov Report
Merging #39 (f4e8243) into main (2502471) will decrease coverage by
0.24%. The diff coverage is50.00%.
@@ Coverage Diff @@
## main #39 +/- ##
==========================================
- Coverage 57.45% 57.21% -0.25%
==========================================
Files 4 4
Lines 181 194 +13
==========================================
+ Hits 104 111 +7
- Misses 77 83 +6
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/GraphViz.jl | 63.72% <50.00%> (-2.21%) |
:arrow_down: |
| src/cairo.jl | 75.00% <0.00%> (+1.00%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 2502471...f4e8243. Read the comment docs.
Could you add a testcase for the new behavior? I think there's a separate callback (agusererrf) for capturing error messages.