Class SequentialScopeExceptionHandling
java.lang.Object
org.logicmachine.rebl.integrationTests_5_exceptionHandling.ExceptionHandlingBase
org.logicmachine.rebl.integrationTests_5_exceptionHandling.SequentialScopeExceptionHandling
This class contains use-case examples of exception handling in sequential scopes.
This illustrates how exception handlers can (optionally) be attached to a scope and how each exception handler can decide if it knows how to handle a specific exception.
Exceptions will bubble-up through the hierarchy of scopes until either an exception handler deals with this specific exception, or the top-level (catch-all) default exception handler deals with it.
This catch-all exception handler is associated with the implicit top-level default scope. Indeed the primary purpose of the top-level default scope is simply to hold this default exception handler.
This illustrates how exception handlers can (optionally) be attached to a scope and how each exception handler can decide if it knows how to handle a specific exception.
Exceptions will bubble-up through the hierarchy of scopes until either an exception handler deals with this specific exception, or the top-level (catch-all) default exception handler deals with it.
This catch-all exception handler is associated with the implicit top-level default scope. Indeed the primary purpose of the top-level default scope is simply to hold this default exception handler.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.logicmachine.rebl.integrationTests_5_exceptionHandling.ExceptionHandlingBase
ExceptionHandlingBase.MyExceptionAction, ExceptionHandlingBase.MyExceptionHandler
-
Field Summary
Fields inherited from class org.logicmachine.rebl.integrationTests_5_exceptionHandling.ExceptionHandlingBase
entity1, entity2, exceptionHandler1, exceptionHandler2, exceptionHandler3, language, scopeA, scopeB, scopeC, scopeD, scopeE, scopeF, throwExceptionInScopeC, throwExceptionInScopeF
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Platform entry-point, invoking the core application functionality.protected void
This method creates a number of exception handler instances and attaches these to various scopes.protected void
Creates the scopes required by this example.void
Should trigger an exception in scope C which will bubble up through scope A before being caught in the top-level default scope and handled by the exception handler associated with the default scope.void
Should trigger an exception in scope F which will bubble up through scope E (where the exception matcher will not match the exception and therefore the exception handler in scope E will ignore it) before being caught in the parent scope D and handled by the exception handler associated with scope D.protected void
verify()
Verifies that the expected exception has been thrown and has been handled by the correct exception handler.Methods inherited from class org.logicmachine.rebl.integrationTests_5_exceptionHandling.ExceptionHandlingBase
call, clear, setupEntitiesForScopes, setupLanguage, start, verifyExceptionHanderActivated, verifyExceptionHanderNotActivated, verifyExceptionHandled, verifyExceptionNotHandled, wantAnExceptionInScopeC, wantAnExceptionInScopeF
-
Constructor Details
-
SequentialScopeExceptionHandling
public SequentialScopeExceptionHandling()Default constructor.
-
-
Method Details
-
main
Platform entry-point, invoking the core application functionality.- Parameters:
args
- the standard platform arguments (not used)
-
shouldCatchExceptionInDefaultScope
public void shouldCatchExceptionInDefaultScope()Should trigger an exception in scope C which will bubble up through scope A before being caught in the top-level default scope and handled by the exception handler associated with the default scope. -
shouldCatchExceptionInParentScope
public void shouldCatchExceptionInParentScope()Should trigger an exception in scope F which will bubble up through scope E (where the exception matcher will not match the exception and therefore the exception handler in scope E will ignore it) before being caught in the parent scope D and handled by the exception handler associated with scope D. -
setupScopes
protected void setupScopes()Creates the scopes required by this example.
This method will define the following scope hierarchy:
A(C), B(D(E(F)))
Which can also be depicted as follows:
DefaultScope
|
|---> A
| |---> C
|
|---> B
| |---> D
| |---> E
| |---> F
In this example, an exception will be thrown in scope C which will bubble up through scope A and into the exception handler associated with the implicit top-level default scope.
Similarly, an exception will be thrown in scope F, which will bubble up through scope E (where it will be ignored by the scope E exception handler since it will not match the type of exception monitored by this exception handler) before being handled by the exception handler associated with scope D.- Specified by:
setupScopes
in classExceptionHandlingBase
-
setupExceptionHandlers
protected void setupExceptionHandlers()Description copied from class:ExceptionHandlingBase
This method creates a number of exception handler instances and attaches these to various scopes.- Specified by:
setupExceptionHandlers
in classExceptionHandlingBase
-
verify
protected void verify()Description copied from class:ExceptionHandlingBase
Verifies that the expected exception has been thrown and has been handled by the correct exception handler.- Specified by:
verify
in classExceptionHandlingBase
-