File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 5
5
import java .io .InputStream ;
6
6
import java .io .UncheckedIOException ;
7
7
import java .util .Map ;
8
+ import java .nio .charset .StandardCharsets ;
8
9
import java .nio .file .Files ;
9
10
import java .nio .file .StandardCopyOption ;
10
11
@@ -651,15 +652,17 @@ public GetVersion_Result getVersion(GetVersion_Args args) throws Exception {
651
652
private byte [] call (String name , byte [] args ) throws Exception {
652
653
byte [] result = callNative (name .getBytes (), args );
653
654
if (result != null && startsWith (result , ERROR_PREFIX )) {
654
- throw new java .lang .Error (result .toString ().substring (ERROR_PREFIX .length ()).trim ());
655
+ String resultString = new String (result , StandardCharsets .UTF_8 );
656
+ throw new Exception (resultString .substring (ERROR_PREFIX .length ()).trim ());
655
657
}
656
658
return result ;
657
659
}
658
660
659
661
private byte [] callLoadPackageWithCache (byte [] args ) throws Exception {
660
662
byte [] result = loadPackageWithCache (args );
661
663
if (result != null && startsWith (result , ERROR_PREFIX )) {
662
- throw new java .lang .Error (result .toString ().substring (ERROR_PREFIX .length ()).trim ());
664
+ String resultString = new String (result , StandardCharsets .UTF_8 );
665
+ throw new Exception (resultString .substring (ERROR_PREFIX .length ()).trim ());
663
666
}
664
667
return result ;
665
668
}
Original file line number Diff line number Diff line change @@ -19,4 +19,16 @@ public void testExecProgramApi() throws Exception {
19
19
ExecProgram_Result result = apiInstance .execProgram (args );
20
20
Assert .assertEquals (result .getYamlResult (), "app:\n " + " replicas: 2" );
21
21
}
22
+
23
+ @ Test
24
+ public void testExecProgramApiInvalid () {
25
+ try {
26
+ ExecProgram_Args args = ExecProgram_Args .newBuilder ().build ();
27
+
28
+ API apiInstance = new API ();
29
+ apiInstance .execProgram (args );
30
+ } catch (Exception e ) {
31
+ Assert .assertEquals (e .getMessage (), "No input KCL files or paths" );
32
+ }
33
+ }
22
34
}
You can’t perform that action at this time.
0 commit comments