/**
* Check to see if there was an error processing an rrdtool command
*/
private void checkErrorStream(Process process) throws Exception {
Closer closer = Closer.create();
try {
InputStream is = closer.register(process.getErrorStream());
// rrdtool should use platform encoding (unless you did something
// very strange with your installation of rrdtool). So let's be
// explicit and use the presumed correct encoding to read errors.
InputStreamReader isr = closer.register(new InputStreamReader(is, Charset.defaultCharset()));
BufferedReader br = closer.register(new BufferedReader(isr));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
if (sb.length() > 0) {
throw new RuntimeException(sb.toString());
}
} catch (Throwable t) {
throw closer.rethrow(t);
} finally {
closer.close();
}
}