Skip to content

Commit

Permalink
Fix #118 (partially): Don't print stacktrace on SQL syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondrej Zizka committed Dec 1, 2024
1 parent cd1bc70 commit 1b5e659
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ open class CsvCruncherException : RuntimeException {

class CrucherConfigException : CsvCruncherException {
constructor(message: String?) : super(message)
}
}

class SqlSyntaxCruncherException : CsvCruncherException {
constructor(message: String?) : super(message)
}

9 changes: 9 additions & 0 deletions src/main/kotlin/cz/dynawest/csvcruncher/HsqlDbHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ class HsqlDbHelper(val jdbcConn: Connection) {
jdbcConn.prepareStatement(sql)
}
catch (ex: SQLSyntaxErrorException) {
if (ex.message!!.contains("unexpected token:")) {
throw SqlSyntaxCruncherException("""
| The SQL contains syntax error:
| ${ex.message}
| $sql
| This may be your SQL error or caused by alteration by CsvCruncher.
| See https://github.com/OndraZizka/csv-cruncher/issues for known bugs.
| """.trimMargin())
}
if (ex.message!!.contains("object not found:")) {
throw throwHintForObjectNotFound(ex, this, sql)
}
Expand Down

0 comments on commit 1b5e659

Please sign in to comment.