Package org.eclipse.core.runtime
Class SafeRunner
java.lang.Object
org.eclipse.core.runtime.SafeRunner
Runs the given ISafeRunnable in a protected mode: exceptions and certain
errors thrown in the runnable are logged and passed to the runnable's
exception handler. Such exceptions are not rethrown by this method.
This class can be used without OSGi running.
- Since:
- org.eclipse.equinox.common 3.2
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
run
(ISafeRunnable code) Runs the given runnable in a protected mode.static <T> T
run
(ISafeRunnableWithResult<T> code) Runs the given runnable in a protected mode and returns the result given by the runnable.
-
Constructor Details
-
SafeRunner
public SafeRunner()
-
-
Method Details
-
run
Runs the given runnable in a protected mode. Exceptions thrown in the runnable are logged and passed to the runnable's exception handler. Such exceptions are not rethrown by this method.In addition to catching all
Exception
types, this method also catches certainError
types that typically result from programming errors in the code being executed. Severe errors that are not generally safe to catch are not caught by this method.- Parameters:
code
- the runnable to run
-
run
Runs the given runnable in a protected mode and returns the result given by the runnable. Exceptions thrown in the runnable are logged and passed to the runnable's exception handler. Such exceptions are not rethrown by this method, instead null is returned.In addition to catching all
Exception
types, this method also catches certainError
types that typically result from programming errors in the code being executed. Severe errors that are not generally safe to catch are not caught by this method.- Type Parameters:
T
- the result type- Parameters:
code
- the runnable to run- Returns:
- the result
- Since:
- 3.11
-