diff --git a/native-cli/src/main/scala/org/mule/weave/dwnative/cli/DataWeaveCLI.scala b/native-cli/src/main/scala/org/mule/weave/dwnative/cli/DataWeaveCLI.scala index 464ec2a..7cfd9c1 100644 --- a/native-cli/src/main/scala/org/mule/weave/dwnative/cli/DataWeaveCLI.scala +++ b/native-cli/src/main/scala/org/mule/weave/dwnative/cli/DataWeaveCLI.scala @@ -215,7 +215,7 @@ class DataWeaveCLIRunner { config.scriptToRun.get } - val defaultInputType = Option(System.getenv(DW_DEFAULT_INPUT_MIMETYPE_VAR)).getOrElse("application/json"); + val defaultInputType = Option(System.getenv(DW_DEFAULT_INPUT_MIMETYPE_VAR)).getOrElse("application/json") val scriptingBindings = new ScriptingBindings if (config.inputs.isEmpty) { scriptingBindings.addBinding("payload", System.in, defaultInputType) diff --git a/native-common/src/main/scala/org/mule/weave/dwnative/NativeRuntime.scala b/native-common/src/main/scala/org/mule/weave/dwnative/NativeRuntime.scala index 089aa33..3b72d44 100644 --- a/native-common/src/main/scala/org/mule/weave/dwnative/NativeRuntime.scala +++ b/native-common/src/main/scala/org/mule/weave/dwnative/NativeRuntime.scala @@ -28,6 +28,7 @@ import org.mule.weave.v2.runtime.InputType import org.mule.weave.v2.runtime.ModuleComponents import org.mule.weave.v2.runtime.ModuleComponentsFactory import org.mule.weave.v2.runtime.ScriptingBindings +import org.mule.weave.v2.runtime.ScriptingEngineSetupException import org.mule.weave.v2.sdk.TwoLevelWeaveResourceResolver import org.mule.weave.v2.sdk.WeaveResourceResolver @@ -72,9 +73,11 @@ class NativeRuntime(libDir: File, path: Array[File]) { case le: LocatableException => { WeaveFailureResult(le.getMessage() + " at:\n" + le.location.locationString) } + case se: ScriptingEngineSetupException => { + WeaveFailureResult(se.getMessage) + } case le: Exception => { val writer = new StringWriter() - le.printStackTrace() le.printStackTrace(new PrintWriter(writer)) WeaveFailureResult("Internal error : " + le.getClass.getName + " : " + le.getMessage + "\n" + writer.toString) } diff --git a/native-common/src/main/scala/org/mule/weave/dwnative/utils/DataWeaveUtils.scala b/native-common/src/main/scala/org/mule/weave/dwnative/utils/DataWeaveUtils.scala index a86bca2..6a08da6 100644 --- a/native-common/src/main/scala/org/mule/weave/dwnative/utils/DataWeaveUtils.scala +++ b/native-common/src/main/scala/org/mule/weave/dwnative/utils/DataWeaveUtils.scala @@ -43,7 +43,11 @@ object DataWeaveUtils { if(dwScriptPath != null) { val scriptPath = new File(dwScriptPath) if(scriptPath.isFile && scriptPath.getName == "dw"){ - return scriptPath.getCanonicalFile.getParentFile + val homeDirectory = scriptPath.getCanonicalFile.getParentFile.getParentFile + if (WeaveProperties.verbose) { + println(s"[debug] Home Directory detected from script at ${homeDirectory.getAbsolutePath}") + } + return homeDirectory } } println(AnsiColor.yellow(s"[warning] Unable to detect Weave Home directory so local directory is going to be used. Please either define the env variable WEAVE_HOME or copy the weave distro into `${defaultDWHomeDir.getAbsolutePath}`."))