|
1 | 1 | package org.togetherjava.jshellapi.service; |
2 | 2 |
|
3 | 3 | import org.apache.tomcat.util.http.fileupload.util.Closeable; |
| 4 | +import org.togetherjava.jshellapi.dto.JShellExceptionResult; |
4 | 5 | import org.togetherjava.jshellapi.dto.JShellResult; |
5 | 6 | import org.togetherjava.jshellapi.dto.SnippetStatus; |
6 | 7 | import org.togetherjava.jshellapi.dto.SnippetType; |
@@ -91,14 +92,20 @@ public Optional<JShellResult> eval(String code) throws DockerException { |
91 | 92 | String source = desanitize(reader.readLine()); |
92 | 93 | String result = reader.readLine(); |
93 | 94 | if(result.equals("NONE")) result = null; |
| 95 | + String rawException = reader.readLine(); |
| 96 | + JShellExceptionResult exception = null; |
| 97 | + if(!rawException.isEmpty()) { |
| 98 | + String[] split = rawException.split(":"); |
| 99 | + exception = new JShellExceptionResult(split[0], split[1]); |
| 100 | + } |
94 | 101 | boolean stdoutOverflow = Boolean.parseBoolean(reader.readLine()); |
95 | 102 | String stdout = desanitize(reader.readLine()); |
96 | 103 | List<String> errors = new ArrayList<>(); |
97 | 104 | String error; |
98 | 105 | while(!(error = reader.readLine()).isEmpty()) { |
99 | 106 | errors.add(desanitize(error)); |
100 | 107 | } |
101 | | - return Optional.of(new JShellResult(status, type, id, source, result, stdoutOverflow, stdout, errors)); |
| 108 | + return Optional.of(new JShellResult(status, type, id, source, result, exception, stdoutOverflow, stdout, errors)); |
102 | 109 | } catch (IOException | NumberFormatException ex) { |
103 | 110 | close(); |
104 | 111 | throw new DockerException(ex); |
|
0 commit comments