Usages of moldable exceptions in Glamorous Toolkit

This page gives example of Moldable exception used in Glamorous Toolkit.


AssertionFailure Error subclass: #AssertionFailure instanceVariableNames: '' classVariableNames: '' package: 'Kernel-Exceptions' defines a debugging configuration, that at the moment shows a diff view when two strings are being compared.

	assert: GtExampleComparisonExceptionWithDebuggingViews new
	equals: GtExampleComparisonExceptionWithDebuggingViews new

An AssertionFailure that does not involve a comporison does not trigger the error.

self assert: 1 = 2


Warning Notification subclass: #Warning instanceVariableNames: '' classVariableNames: '' package: 'Kernel-Exceptions' notifications define that direcly shows the message and allows the user to proceed.

Warning signal: 'I am a warning message'


GtPhlowViewTesterObjectValidationFailure GtPhlowViewTesterFailure subclass: #GtPhlowViewTesterObjectValidationFailure instanceVariableNames: 'object results' classVariableNames: '' package: 'GToolkit-Phlow-Examples-Tester' is an assertion failure indicating that there is an error in the view of an object. See How to test phlow views for other examples of views with errors.

self assertObjectPhlowViewsFor: GtPhlowViewWithErrorExamples new.


GtPhlowViewTesterViewValidationFailure GtPhlowViewTesterFailure subclass: #GtPhlowViewTesterViewValidationFailure instanceVariableNames: 'actualResult expectedResult' classVariableNames: '' package: 'GToolkit-Phlow-Examples-Tester' indicates that there is an error inside a single view of an object.

GtPhlowViewTester new 
	assertViewOk: (GtPhlowViewWithErrorExamples new 
		gtViewWithFailureInColumnedListFor: GtPhlowView empty)


GtPhlowViewsCollectorSameViewError GtPhlowViewsCollectorError subclass: #GtPhlowViewsCollectorSameViewError uses: TGtMoldableExceptionSignalWithTransformation instanceVariableNames: 'viewSelector targetObject' classVariableNames: '' package: 'GToolkit-DebuggerExtensions-ViewsCollector' is triggered when building a view if the same view that was given as parameter is returned.

viewBuilder := GtPhlowView empty. 
	basicOn: GtPhlowViewWithErrorExamples new 
	perform: #gtViewWithReturningSameViewFor:
	withArguments: {viewBuilder}.

Not in all cases we can easily determine the place where the empty view is created.

viewBuilder := GtPhlowView empty. 
	basicOn: GtPhlowViewWithErrorExamples new 
	perform: #gtViewWithReturningIndirectlySameViewFor:
	withArguments: {viewBuilder}.


BlSingularMatrixError ArithmeticError subclass: #BlSingularMatrixError instanceVariableNames: 'targetMatrix' classVariableNames: '' package: 'Bloc-Basic-Math' is thrown when trying to inverse a singular (non-invertible or degenerate) matrix.

element := BlElement new
	size: 0@0;
	transformDo: [ :t | 
		t scaleBy: 0 .
		t translateBy: 10@5.
		t rotateBy: 25.
		t shearBy: 2@3 ].
element globalPointToLocal: 10@10


ZnTooManyRedirects Error subclass: #ZnTooManyRedirects instanceVariableNames: 'trail' classVariableNames: '' package: 'Zinc-HTTP-Exceptions' error has a debugging action for inceasing the number of redirects and retrying the request.

ZnClient new 
	url: '';
	maxNumberOfRedirects: 3;


The ConnectionTimedOut NetworkError subclass: #ConnectionTimedOut instanceVariableNames: '' classVariableNames: '' package: 'Network-Kernel-Exceptions' error has two debugging actions that make it possible to

- inceasing the timeout in the current ZnClient Object subclass: #ZnClient instanceVariableNames: 'request response connection lastUsed options session logLevel newOptions' classVariableNames: '' package: 'Zinc-HTTP-Client-Server' instance and retry the request,

- continue reading/writting data with a new timeout set.

ZnServer startDefaultOn: 1701.

ZnClient new
	url: ZnServer default localUrl / #echo;
	timeout: 2;
	queryAt: #delay put: 10;

ZnClient errors

The method ZnClient>>#retryExceptionSet retryExceptionSet ^ NetworkError, ZnParseError, ZnCharacterEncodingError, ZnUnknownScheme, ZnPortNotANumber defines a list of exceptions that Zinc handles by doing a retry.

The debugging action GtZnClientFailedRequestRetryDebugAction DebugAction subclass: #GtZnClientFailedRequestRetryDebugAction instanceVariableNames: '' classVariableNames: '' package: 'GToolkit-DebuggerExtensions-Zinc' offers the possibility to increase the number of allowed retries and retry execution.

client := ZnClient new 
	url: '';
	numberOfRetries: 2;