[HOW TO] Soft assertions with support for error reporting

Is it possible to do "handled" assertions that do not break the code execution but are handled by the standard error reporting interface (i.e. show error notification at the right bottom of the screen and allow reporting the error like any other fatal exception in IDEA)

Sample usage: operations requiring slow third party connections should not be executed in dispatch thread (causing the ide to freeze) => throw assertion error without breaking the code execution, but allow reporting that error


Hi Dan,

You can just create a com.intellij.openapi.diagnostic.Logger instance like below

private static final Logger LOG = Logger.getInstance("#<your class name>");
and call LOG.error(); on it

embarrassingly trivial.. why didn't I think of that? I ended up creating the assertion error and throwing it from a new thread :) ..worked though...
Thanks Denis


Please sign in to leave a comment.