Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic exception handling #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

frankier
Copy link

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
Copy link

codecov bot commented Feb 11, 2022

Codecov Report

Merging #39 (f4e8243) into main (2502471) will decrease coverage by 0.24%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            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%) ⬇️
src/cairo.jl 75.00% <0.00%> (+1.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2502471...f4e8243. Read the comment docs.

@Keno
Copy link
Contributor

Keno commented Feb 11, 2022

Could you add a testcase for the new behavior? I think there's a separate callback (agusererrf) for capturing error messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants