Skip to content

Commit

Permalink
feat(GraphViz): Add basic error handling
Browse files Browse the repository at this point in the history
Signed-off-by: Gordon Smith <gordonjsmith@gmail.com>
  • Loading branch information
GordonSmith committed Feb 27, 2020
1 parent 1468762 commit 5e58238
Show file tree
Hide file tree
Showing 11 changed files with 1,101 additions and 2,819 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ install:
- npm run install-prerequisites
- npm run install-build-deps
before_script:
- npm run lint;
- npm run build;
- npm run lint
- npm run dev-start &
- npm run build
6 changes: 6 additions & 0 deletions cpp/graphviz/graphvizlib/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ char *vizLastErrorMessage()

const char *Main::layout(const char *src, const char *format, const char *engine)
{
errorMessage = NULL;
char *result = NULL;
GVC_t *context;
Agraph_t *graph;
Expand Down Expand Up @@ -53,6 +54,11 @@ const char *Main::layout(const char *src, const char *format, const char *engine
return result;
}

const char *Main::lastError()
{
return errorMessage;
}

// Patch for invalid osage function ---
// https://gitlab.com/graphviz/graphviz/issues/1544
#include "types.h"
Expand Down
1 change: 1 addition & 0 deletions cpp/graphviz/graphvizlib/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ class Main
{
public:
static const char *layout(const char *dot, const char *format, const char *engine);
static const char *lastError();
};
1 change: 1 addition & 0 deletions cpp/graphviz/graphvizlib/main.idl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
interface Main {
[Const] static DOMString layout([Const] DOMString dot, [Const] DOMString format, [Const] DOMString engine);
[Const] static DOMString lastError();
};
10 changes: 7 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,20 @@ <h3>End</h3>
hpccWasm.graphviz.layout(dot, "svg", "dot").then(svg => {
const div = document.getElementById("placeholder");
div.innerHTML = svg;
});
}).catch(err => console.error(err.message));

hpccWasm.graphviz.layout(dot, "svg", "dot").then(svg => {
const div = document.getElementById("placeholder2");
div.innerHTML = svg;
});
}).catch(err => console.error(err.message));

hpccWasm.graphvizSync().then(graphviz => {
const div = document.getElementById("placeholder3");
div.innerHTML = graphviz.layout(dot, "svg", "dot");
try {
div.innerHTML = graphviz.layout(dot, "svg", "dot");
} catch (e) {
div.innerHTML = e.message;
}
});
</script>

Expand Down
33 changes: 0 additions & 33 deletions karma.conf.js

This file was deleted.

0 comments on commit 5e58238

Please sign in to comment.