Usages of moldable exceptions in Glamorous Toolkit

This page gives examples of Moldable exceptions used in Glamorous Toolkit.

AssertionFailure

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 compared.

self 
	assert: GtExampleComparisonExceptionWithDebuggingViews new
		expectedStringForTest 
	equals: GtExampleComparisonExceptionWithDebuggingViews new
		computedStringForTest
  

An AssertionFailure that does not involve a comparison does not trigger that error.

self assert: 1 = 2
  

Warnings

Warning Notification subclass: #Warning instanceVariableNames: '' classVariableNames: '' package: 'Kernel-Exceptions' notifications directly show the message and allow the user to proceed.

Warning signal: 'I am a warning message'
  

GtPhlowViewTesterObjectValidationFailure

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

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

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. 
viewBuilder
	basicOn: GtPhlowViewWithErrorExamples new 
	perform: #gtViewWithReturningSameViewFor:
	withArguments: {viewBuilder}.
  

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

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

BlSingularMatrixError

BlSingularMatrixError ArithmeticError subclass: #BlSingularMatrixError instanceVariableNames: 'targetMatrix' classVariableNames: '' package: 'Bloc-Core-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

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: 'https://www.gmail.com';
	maxNumberOfRedirects: 3;
	get 
  

ConnectionTimedOut

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

- increasing 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/writing data with a new timeout set.

ZnServer startDefaultOn: 1701.

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

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: 'https://www.noexistingurl.com';
	numberOfRetries: 2;
	get