Skip to content

Commit

Permalink
Do not print stack trace
Browse files Browse the repository at this point in the history
Summary: This was missed on the changes from #476, but luckily our internal tests caught it when I tried to sent out a new release.

Reviewed By: strulovich

Differential Revision: D58528471

fbshipit-source-id: ea4824b295f452b1dc0f7d868664e6792ba07c9c
  • Loading branch information
Nivaldo Bondança authored and facebook-github-bot committed Jun 14, 2024
1 parent 96d9435 commit cef16a6
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions core/src/main/java/com/facebook/ktfmt/cli/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ class Main(
}

fun run(): Int {
val processArgs = ParsedArgs.processArgs(inputArgs)
val parsedArgs =
when (processArgs) {
when (val processArgs = ParsedArgs.processArgs(inputArgs)) {
is ParseResult.Ok -> processArgs.parsedValue
is ParseResult.ShowMessage -> {
out.println(processArgs.message)
Expand All @@ -103,8 +102,7 @@ class Main(
val alreadyFormatted = format(null, parsedArgs)
if (!alreadyFormatted && parsedArgs.setExitIfChanged) EXIT_CODE_FAILURE
else EXIT_CODE_SUCCESS
} catch (e: Exception) {
e.printStackTrace(err)
} catch (_: Exception) {
EXIT_CODE_FAILURE
}
}
Expand All @@ -116,18 +114,17 @@ class Main(
return EXIT_CODE_FAILURE
}

val retval = AtomicInteger(EXIT_CODE_SUCCESS)
val returnCode = AtomicInteger(EXIT_CODE_SUCCESS)
files.parallelStream().forEach {
try {
if (!format(it, parsedArgs) && parsedArgs.setExitIfChanged) {
retval.set(EXIT_CODE_FAILURE)
returnCode.set(EXIT_CODE_FAILURE)
}
} catch (e: Exception) {
e.printStackTrace(err)
retval.set(EXIT_CODE_FAILURE)
} catch (_: Exception) {
returnCode.set(EXIT_CODE_FAILURE)
}
}
return retval.get()
return returnCode.get()
}

/**
Expand Down

0 comments on commit cef16a6

Please sign in to comment.