use of org.dbflute.exception.DfFireSqlScriptSQLException in project dbflute-core by dbflute.
the class DfSqlFileFireMan method executeScriptFile.
protected DfSqlFileRunnerResult executeScriptFile(DfSqlFileRunner runner, SystemScript script, File sqlFile) {
final String sqlPath = resolvePath(sqlFile);
final String baseDir = Srl.substringLastFront(sqlPath, "/");
final String scriptName = Srl.substringLastRear(sqlPath, "/");
_log.info("...Executing the script: " + sqlPath);
final ProcessResult processResult;
try {
processResult = script.execute(new File(baseDir), scriptName);
} catch (SystemScriptUnsupportedScriptException ignored) {
_log.info("Skipped the script for system mismatch: " + scriptName);
return null;
}
final String console = processResult.getConsole();
if (Srl.is_NotNull_and_NotTrimmedEmpty(console)) {
_log.info("Caught the console for " + scriptName + ":" + ln() + console);
}
final DfSqlFileRunnerResult runnerResult = new DfSqlFileRunnerResult(sqlFile);
runnerResult.setTotalSqlCount(1);
final int exitCode = processResult.getExitCode();
if (exitCode != 0) {
final String msg = "The script failed: " + scriptName + " exitCode=" + exitCode;
// wrapping quickly because SQLFailureException needs SQLException
// (and nested exception message has debug information so simple message here)
final SQLException sqlEx = new DfFireSqlScriptSQLException(msg);
final SQLFailureException failureEx = new SQLFailureException("Break the process for script failure.", sqlEx);
// no error continue, script error is treated as programming error
// because you can freely skip SQL failure in your script
runnerResult.setBreakCause(failureEx);
return runnerResult;
} else {
runnerResult.setGoodSqlCount(1);
return runnerResult;
}
}
Aggregations