Examples of moldable exceptions
This page shows several examples of Moldable Exceptions together with code snipepts for working with them.
GtExampleExceptionWithDebuggingView
is an exception that defines a single debugging view using #selector
. It uses the default extensions without any configuration.
exception := GtExampleExceptionWithDebuggingView new expectedString: GtExampleComparisonExceptionWithDebuggingViews new expectedShortStringForTest; actualString: GtExampleComparisonExceptionWithDebuggingViews new computedShortStringForTest. exception signal.
GtExampleComparisonExceptionWithDebuggingViews
is an exception that defines two debugging views.
exception := GtExampleComparisonExceptionWithDebuggingViews new expectedString: GtExampleComparisonExceptionWithDebuggingViews new expectedStringForTest; actualString: GtExampleComparisonExceptionWithDebuggingViews new computedStringForTest; targetClass: GtExampleComparisonExceptionWithDebuggingViews; targetSelector: #expectedStringForTest. exception signal.
Another way to get this exception is by using GtExampleExceptionComparisonTriggerExamples>>#testComputation
GtExampleExceptionWithForwardedDebuggingView
is an exception that has multiple debugging views defined in other domain objects. These objects where views are defined are speciffied by specializing the default configuration in #selector
.
exception := GtExampleExceptionWithForwardedDebuggingView new initializeWithDomainData. exception signal.