Skip to content

Commit

Permalink
Made ktlint print RuleExecutionException stacktrace when in --debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
shyiko committed Jul 24, 2017
1 parent e538e53 commit c3ec632
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ktlint/src/main/kotlin/com/github/shyiko/ktlint/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,16 @@ ${ByteArrayOutputStream().let { this.printUsage(it); it }.toString().trimEnd().s
fun lintErrorFrom(e: Exception): LintError = when (e) {
is ParseException ->
LintError(e.line, e.col, "",
"Not a valid Kotlin file (${e.message?.toLowerCase()})")
is RuleExecutionException ->
"Not a valid Kotlin file (${e.message?.toLowerCase()})")
is RuleExecutionException -> {
if (debug) {
System.err.println("[DEBUG] Internal Error (${e.ruleId})")
e.printStackTrace(System.err)
}
LintError(e.line, e.col, "", "Internal Error (${e.ruleId}). " +
"Please create a ticket at https://github.com/shyiko/ktlint/issue " +
"(if possible, provide the source code that triggered an error)")
"Please create a ticket at https://github.com/shyiko/ktlint/issue " +
"(if possible, provide the source code that triggered an error)")
}
else -> throw e
}
val tripped = AtomicBoolean()
Expand Down

0 comments on commit c3ec632

Please sign in to comment.