Redirect PSI errors to the default exception handler#111
Redirect PSI errors to the default exception handler#111yevhenii-nadtochii merged 9 commits intomasterfrom
Conversation
armiol
left a comment
There was a problem hiding this comment.
@yevhenii-nadtochii as discussed vocally, let's adjust both the default behaviour of the exception handler. And the documentation of the public member.
alexander-yevsyukov
left a comment
There was a problem hiding this comment.
Please see my comments.
| */ | ||
| private fun logAndTerminate(t: Throwable) { | ||
| t.printStackTrace() | ||
| exitProcess(1) |
There was a problem hiding this comment.
1 should be a constant visible somewhere in the public documentation. Please see how we do it in ProtoData.
There was a problem hiding this comment.
BTW, we probably should use 1 there too because ProtoData usually exits with 255.
| errorHandler(t) | ||
| } | ||
| } | ||
| executeSilent(withHandledErrors) |
There was a problem hiding this comment.
This code combination is confusing because it won't result in the really silent execution.
| * The default error handler for [execute] that logs the given [Throwable] to [System.err] | ||
| * and terminates the currently running process with a non-zero exit code. | ||
| */ | ||
| private fun logAndTerminate(t: Throwable) { |
There was a problem hiding this comment.
We don't really log here. We print the stacktrace to the console.
| * @see execute | ||
| */ | ||
| @JvmName("executeSilent") | ||
| public fun executeSilent(runnable: Runnable) { |
There was a problem hiding this comment.
Why do we need this, assuming we have the default value for execute?
|
@armiol @alexander-yevsyukov PTAL I've removed usages of the exception handler because we can throw right away now. |
armiol
left a comment
There was a problem hiding this comment.
@yevhenii-nadtochii LGTM from my side.
This PR wraps the
runnablewe give to PSI into atry-catchblock, with the configurable possibility to throw right away.We need this change, so that users of ProtoData could see these errors.
I have tested this approach locally with changes to
tool-baseandProtoData, it works. And I have not found any usages ofcommandProcessor.executeCommand()out of this extension, which we use as an entry point to PSI modifications.Addresses problem (2) described in this comment.