File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
graphviz-java/src/main/java/guru/nidi/graphviz/engine Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 1515 */
1616package guru .nidi .graphviz .engine ;
1717
18- import com .eclipsesource .v8 .*;
18+ import com .eclipsesource .v8 .V8 ;
19+ import com .eclipsesource .v8 .V8RuntimeException ;
1920import org .slf4j .Logger ;
2021import org .slf4j .LoggerFactory ;
2122
@@ -78,10 +79,16 @@ private static class Env implements AutoCloseable {
7879 LOG .info ("Started V8 runtime. Initializing graphviz..." );
7980 v8 .executeVoidScript (viz );
8081 v8 .executeVoidScript (init );
81- v8 .registerJavaMethod ((JavaVoidCallback ) (receiver , parameters ) ->
82- resultHandler .setResult (parameters .getString (0 )), "result" );
83- v8 .registerJavaMethod ((JavaVoidCallback ) (receiver , parameters ) ->
84- resultHandler .setError (parameters .getString (0 )), "error" );
82+ v8 .registerJavaMethod ((receiver , parameters ) -> {
83+ resultHandler .setResult (parameters .getString (0 ));
84+ }, "result" );
85+ v8 .registerJavaMethod ((receiver , parameters ) -> {
86+ final String rawMsg = parameters .getString (0 );
87+ final String msg = rawMsg .matches ("TypeError: Module\\ ..*? is not a function" )
88+ ? "Got Error: '" + rawMsg + "'. This is probably an out of memory error. Try using the totalMemory method."
89+ : rawMsg ;
90+ resultHandler .setError (msg );
91+ }, "error" );
8592 LOG .info ("Initialized graphviz." );
8693 }
8794
You can’t perform that action at this time.
0 commit comments