-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirect PSI errors to the default exception handler #111
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yevhenii-nadtochii as discussed vocally, let's adjust both the default behaviour of the exception handler. And the documentation of the public member.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comments.
*/ | ||
private fun logAndTerminate(t: Throwable) { | ||
t.printStackTrace() | ||
exitProcess(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yevhenii-nadtochii LGTM from my side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR wraps the
runnable
we give to PSI into atry-catch
block, 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-base
andProtoData
, 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.