11package com .grimpirate ;
22
33import java .awt .Dimension ;
4- import java .io .FileNotFoundException ;
5- import java .io .IOException ;
64import java .time .LocalDateTime ;
75import java .time .format .DateTimeFormatter ;
86import java .util .Arrays ;
1614public class JavaScript
1715{
1816 private CoordinateText [] texts ;
19-
20- public JavaScript (String js , String version , Dimension dimension ) throws FileNotFoundException , IOException
17+
18+ public JavaScript (String js , String version , Dimension dimension )
2119 {
2220 Context context = Context .enter ();
2321 Scriptable scope = new ImporterTopLevel (context );
@@ -30,11 +28,17 @@ public JavaScript(String js, String version, Dimension dimension) throws FileNot
3028 ScriptableObject .putConstProperty (host , "os_arch" , Context .javaToJS (System .getProperty ("os.name" ) + " " + System .getProperty ("os.arch" ), scope ));
3129 ScriptableObject .putConstProperty (host , "time" , Context .javaToJS (LocalDateTime .now ().format (DateTimeFormatter .ofPattern ("yyyy-MM-dd HH:mm:ss" )), scope ));
3230 ScriptableObject .putConstProperty (scope , "SVGWall" , Context .javaToJS (host , scope ));
33- CoordinateText [] texts = Arrays .stream (((NativeArray ) context .evaluateReader (scope , new java .io .FileReader (js ), "<cmd>" , 1 , null )).toArray ()).toArray (CoordinateText []::new );
34- Context .exit ();
35- this .texts = texts ;
31+ try
32+ {
33+ texts = Arrays .stream (((NativeArray ) context .evaluateReader (scope , new java .io .FileReader (js ), "<cmd>" , 1 , null )).toArray ()).toArray (CoordinateText []::new );
34+ }
35+ catch (Exception e )
36+ {
37+ Context .exit ();
38+ texts = new CoordinateText [] {};
39+ }
3640 }
37-
41+
3842 public CoordinateText [] getText ()
3943 {
4044 return texts ;
0 commit comments