@@ -173,27 +173,34 @@ public void attach(int processId) {
173173 isRunning = true ;
174174 }
175175 } catch (Exception e ) {
176- ByteArrayOutputStream stream = new ByteArrayOutputStream ();
176+ /* ByteArrayOutputStream stream = new ByteArrayOutputStream();
177177 PrintStream ps = new PrintStream(stream);
178178 e.printStackTrace(ps);
179- session .getConsoleView ().print (stream .toString (), ConsoleViewContentType .ERROR_OUTPUT );
179+ session.getConsoleView().print(stream.toString(), ConsoleViewContentType.ERROR_OUTPUT);*/
180+ session .getConsoleView ().print (e .getMessage (), ConsoleViewContentType .ERROR_OUTPUT );
180181 session .stop ();
181182 isRunning = false ;
182183 }
183184 }
184185
185- public void launch (@ NotNull String program , @ NotNull String wd , String [] args ) {
186+ public void launch (@ NotNull String program , String workingDir , String [] args ) {
186187 VirtualFile pluginVirtualDirectory = LuaFileUtil .getPluginVirtualDirectory ();
187188 try {
188189 if (pluginVirtualDirectory != null ) {
189- // check arch
190+ if (workingDir == null || workingDir .isEmpty ()) {
191+ throw new Exception ("Working directory not found." );
192+ }
193+
190194 // check arch
191195 String archExe = LuaFileUtil .getPluginVirtualFile ("debugger/windows/Arch.exe" );
192196 ProcessBuilder processBuilder = new ProcessBuilder (archExe );
193197 boolean isX86 ;
194198 Process archChecker = processBuilder .command (archExe , "-file" , program ).start ();
195199 archChecker .waitFor ();
196200 int exitValue = archChecker .exitValue ();
201+ if (exitValue == -1 ) {
202+ throw new Exception (String .format ("Program [%s] not found." , program ));
203+ }
197204 isX86 = exitValue == 1 ;
198205
199206 String archType = isX86 ? "x86" : "x64" ;
@@ -205,9 +212,9 @@ public void launch(@NotNull String program, @NotNull String wd, String[] args) {
205212 argList .add (exe );
206213 argList .add ("-m" ); argList .add ("run" );
207214 argList .add ("-c" ); argList .add (program );
208- if (!wd .isEmpty ()) {
215+ if (!workingDir .isEmpty ()) {
209216 argList .add ("-w" );
210- argList .add (wd );
217+ argList .add (workingDir );
211218 }
212219 if (args != null ) {
213220 String argString = String .join (" " , args );
@@ -230,10 +237,11 @@ public void launch(@NotNull String program, @NotNull String wd, String[] args) {
230237 isRunning = true ;
231238 }
232239 } catch (Exception e ) {
233- ByteArrayOutputStream stream = new ByteArrayOutputStream ();
240+ /* ByteArrayOutputStream stream = new ByteArrayOutputStream();
234241 PrintStream ps = new PrintStream(stream);
235242 e.printStackTrace(ps);
236- session .getConsoleView ().print (stream .toString (), ConsoleViewContentType .ERROR_OUTPUT );
243+ session.getConsoleView().print(stream.toString(), ConsoleViewContentType.ERROR_OUTPUT);*/
244+ session .getConsoleView ().print (e .getMessage (), ConsoleViewContentType .ERROR_OUTPUT );
237245 session .stop ();
238246 isRunning = false ;
239247 }
0 commit comments