Skip to content

Commit

Permalink
[Ruby] Add error output (OpenAPITools#5428)
Browse files Browse the repository at this point in the history
* Add error output to the log so that we can make sure why the error occurred

* Fix forbidden method invocation using default charsets
  • Loading branch information
ackintosh authored and MikailBag committed Mar 23, 2020
1 parent 8f4a108 commit fcde0a9
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Locale;

Expand Down Expand Up @@ -200,7 +203,13 @@ public void postProcessFile(File file, String fileType) {
Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor();
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
BufferedReader br = new BufferedReader(new InputStreamReader(p.getErrorStream(), StandardCharsets.UTF_8));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
LOGGER.error("Error running the command ({}). Exit value: {}, Error output: {}", command, exitValue, sb.toString());
} else {
LOGGER.info("Successfully executed: " + command);
}
Expand Down

0 comments on commit fcde0a9

Please sign in to comment.