In my Intellij plugin how can i intercept Runtime Errors of the running program.


I am writing a plugin in IntelliJ using IntelliJ Plugin SDK. I want my plugin to intercept an Error when a program throws a Runtime Exception during its execution or processing. 

Please any kind of assistance will be helpful.  



Executed process and IDE process are totally separate, and it is not possible to intercept exceptions from one in another.

If it is not what you mean, please describe your use case in detail.


First of all, thank you very much for responding to my query

Let me try to explain my problem in detail. I want to add a feature to my plugin that monitors the logs printed in the Console window. If there is an exception in the log, I can intercept it and perform some actions. What could be the best way to achieve it. 

Any support is appriciated and thanks in advance. 


Do you have custom execution classes implementation, or do you want to hook into Java process console, which is available out of the box? Or maybe into other processes? What actions do you want to perform?


Thank you once again for your response. 

I’ve been attempting to connect to the console of a Java process, but unfortunately, I haven’t been successful. 
I also tried to listen to the ToolWindowManagerListener and get the Logs from ConsoleView Object but unfortunately, also haven’t been successful.
Could you kindly recommend an effective approach to achieve this? Alternatively, if you have any sample code, that would be greatly appreciated


I still don't understand what kind of actions you want to perform. You can try with com.intellij.execution.process.ProcessListener.onTextAvailable. It can be registered with ProcessHandler.addProcessListener.


Thank you very much Karol, I can achieve what I want with the hint you provided. 

I am not using any action but an extension. I was able to solve my problem by extending to RunConfigurationExtension and registered a ProcessListener as you mentioned in your last comment.  Thanks for the hint. 

Issue resolved. 


Please sign in to leave a comment.