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

Crash Error Without Useful Error Message #7

Open
jeremykentbgross opened this issue Feb 14, 2016 · 4 comments
Open

Crash Error Without Useful Error Message #7

jeremykentbgross opened this issue Feb 14, 2016 · 4 comments

Comments

@jeremykentbgross
Copy link

Really basic code usages gives unhelpful error. The target file is generated, but it contains 0 bytes.

var plantuml = require('node-plantuml');
plantuml.generate(
//Example input copied from: http://plantuml.com/PlantUML_Language_Reference_Guide.pdf
"@startuml\n"
+ "Class01 <|-- Class02\n"
+ "Class03 *-- Class04\n"
+ "Class05 o-- Class06\n"
+ "Class07 .. Class08\n"
+ "Class09 -- Class10\n"
+ "@enduml\n"
,{format : 'png' } //options
,function callback(){console.log(arguments);}
).out.pipe(
fs.createWriteStream(
'../docs/generated/test.png"
)
);

events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn java ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1046:32)
at child_process.js:1137:20
at process._tickCallback (node.js:355:11)
at Function.Module.runMain (module.js:503:11)
at startup (node.js:129:16)
at node.js:814:3

package.json contains:
"node-plantuml" : "0.4.4"

I am on Ubuntu 14.04 if that helps.

It is also worth noting that the existing documentation on the github page as well as the npm package is wrong, because the code crashes right away if no "options" parameter is provided. I was only able to deduce what seemed like it should be working code from exploring the source code in the repository.

@jeremykentbgross
Copy link
Author

It seems this was because I didn't have the default-jre installed. I also needed graphviz.

Solved with:
sudo apt-get install default-jre
sudo apt-get install graphviz

Still I wonder if there is a way the lib could more helpfully return info on this for others. In any case, all is well that ends well.

@aduh95
Copy link

aduh95 commented Aug 21, 2019

Antoher problem I am facing in my app, is that I cannot catch the error message to display a fallback to my users:

const plantuml = require("node-plantuml");

console.log("The app starts");
setImmediate(() => console.log("Some async task here"));

try {
  plantuml.generate("./test.puml");
} catch {
  console.warn("Plantuml decoding is not available");
}

console.log("The app continues");

The async task is never hit:

>node plantuml-test.js
The app starts
The app continues
events.js:180
      throw er; // Unhandled 'error' event
      ^

Error: spawn java ENOENT
...

I would expect instead to get the following output:

> node plantuml-test.js
The app starts
Plantuml decoding is not available
The app continues
Some async task here

@markushedvall
Copy link
Owner

Thanks for the input. I misunderstood the error output. I thought spawn threw an error but it's actually an error event.

I've been working on improving error & event handling recently and hope to have a fix for this soon.

const gen = plantuml.generate("./test.puml");
gen.on('error', (err) => console.log(...))

That wan't help you to check if plantuml is available to use in advance though. Maybe it would be a good idea to be able to check java availability, similar how testdot can be used to check grahpviz availability.

@simonvpe
Copy link

+1
I spent a fair bit of time figuring out that my Docker container didn't have Java, and that it was a requirement.

I would suggest mentioning it as a dependency in the documentation in addition to the fix that you are working on.

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

No branches or pull requests

4 participants