use of org.fagu.fmv.soft.exec.exception.NestedException in project fmv by f-agu.
the class GSExceptionKnowAnalyzeTestCase method runPdfToImage.
// *************************************
/**
* @param srcResource
* @param expectedMessage
* @param consumer
* @throws IOException
*/
private void runPdfToImage(String srcResource, String expectedMessage, Consumer<SoftExecutor> consumer) throws IOException {
File folder = new File(System.getProperty("java.io.tmpdir"), "gs-pdf2img-test");
try {
FileUtils.deleteDirectory(folder);
folder.mkdirs();
File srcFile = srcResource != null ? Resource.extract(folder, srcResource) : folder;
File outFile = new File(srcFile.getPath() + ".jpg");
try {
Soft gsSoft = GS.search();
List<String> list = new ArrayList<>();
list.add("-sDEVICE=png16m");
list.add("-sOutputFile=" + outFile.getPath());
list.add("-r200");
list.add("-dNOPAUSE");
list.add("-dBATCH");
list.add("-dSAFER");
list.add("-dFirstPage=1");
list.add("-dLastPage=1");
list.add("-dUseCropBox");
list.add(srcFile.getAbsolutePath());
SoftExecutor customizeExecutor = gsSoft.withParameters(list).workingDirectory(srcFile.getParentFile());
// .logCommandLine(System.out::println);
if (consumer != null) {
consumer.accept(customizeExecutor);
}
customizeExecutor.execute();
fail();
} catch (FMVExecuteException e) {
if (e.isKnown()) {
assertEquals(expectedMessage, e.getExceptionKnown().toString());
} else {
new NestedException(e).messageToLines().forEach(System.out::println);
throw e;
}
}
} finally {
FileUtils.deleteDirectory(folder);
}
}
use of org.fagu.fmv.soft.exec.exception.NestedException in project fmv by f-agu.
the class NoOverwriteDeblock method accept.
@Override
public void accept(ExceptionKnown exceptionKnown) throws IOException {
NestedException nestedException = exceptionKnown.getNestedException();
String lastLine = getLineIfBlocked(nestedException);
if (lastLine != null) {
throw new ProcessBlockedException(lastLine);
}
throw nestedException.getIOException();
}
Aggregations