Better error handling in jvm-launch-util

This commit is contained in:
Kris De Volder
2019-09-11 15:43:06 -07:00
parent 77429351b6
commit 3e5167bd16
2 changed files with 13 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@pivotal-tools/jvm-launch-utils",
"version": "0.0.13",
"version": "0.0.14",
"description": "Provides utilities useful for launching Java processes from node packages.",
"files": [
"src",

View File

@@ -55,15 +55,19 @@ export interface JVM {
* toolsjar and to check whether the JVM is a JDK.
*/
export function findJvm(javaHome?: string) : Promise<JVM | null> {
let javaExe = findJavaExe(javaHome);
if (javaExe) {
return getJavaInfo(javaExe).then(javaProps => new JVMImpl(
javaProps.get("java.home"),
javaExe,
getMajorVersion(javaProps)
));
try {
let javaExe = findJavaExe(javaHome);
if (javaExe) {
return getJavaInfo(javaExe).then(javaProps => new JVMImpl(
javaProps.get("java.home"),
javaExe,
getMajorVersion(javaProps)
));
}
return Promise.resolve(null);
} catch (e) {
return Promise.reject(e);
}
return Promise.resolve(null);
}
/**