Zinc debugging extensions
To facilitate working with Zinc, GT provides several debugging actions and views. This page details these debugging extensions starting from the exceptions that activate them.
ZnTooManyRedirects exception extensions
Exceptions of type ZnTooManyRedirects
Error subclass: #ZnTooManyRedirects
instanceVariableNames: 'trail'
classVariableNames: ''
package: 'Zinc-HTTP-Exceptions'
have a debugging action and a view:
Retry: provides a way to increase the number of redirects 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.
Retrying it done by restarting and resuming execution from the method ZnClient>>#execute
execute
"Execute the currently set up request to generate a response.
Return the #contents of the response, if any."
^ self withDynamicVariablesDo: [
| result |
self prepareRequest.
result := self executeWithTimeout.
self prepareNextRequest.
result ]
.
Implemented by the method ZnTooManyRedirects>>#gtActionRetryWithIncreasingRedirectsFor:inContext:
gtActionRetryWithIncreasingRedirectsFor: anAction inContext: aPhlowActionContext
<gtExceptionAction>
<gtStackAction>
| actionLabel |
(aPhlowActionContext currentDebuggingSession
hasLimitedFullActiveContextForMethod: ZnClient>>#execute)
ifFalse: [ ^ anAction noAction ].
actionLabel := 'Increase the number of redirects in the Zinc client and retry the request'.
^ anAction dropdown
label: 'Retry';
icon: BrGlamorousVectorIcons refresh ;
priority: 50;
id: #'gtTooManyRedirects-retry';
tooltip: actionLabel;
preferredExtent: 650@350;
content: [ :aSourceButton |
| contentElement |
contentElement := GtZnClientTooManyRedirectsRetryElement
forZnClient: signaler
andDebugger: aPhlowActionContext currentDebugger
fromSourceElement: aSourceButton.
contentElement
actionLabel: actionLabel;
retryAction: [ :newCount :currentDebugger |
self
gtActionPerformRetryUsing: currentDebugger
withNewRedirectCount: newCount].
contentElement ]
.
Url trail: a view showing the list of urls through which the request was redirected.
ConnectionTimedOut exception extensions
When a Zinc request leads to a ConnectionTimedOut
NetworkError subclass: #ConnectionTimedOut
instanceVariableNames: ''
classVariableNames: ''
package: 'Network-Kernel-Exceptions'
exception, two debugging actions are activated.
Retry: provides a way to to increase the number of redirects 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.
Retrying it done by restarting and resuming execution from the method ZnClient>>#execute
execute
"Execute the currently set up request to generate a response.
Return the #contents of the response, if any."
^ self withDynamicVariablesDo: [
| result |
self prepareRequest.
result := self executeWithTimeout.
self prepareNextRequest.
result ]
.
Implemented by the method ConnectionTimedOut>>#gtZincActionRetryWithIncreasingTimeoutFor:inContext:
gtZincActionRetryWithIncreasingTimeoutFor: anAction inContext: aPhlowActionContext
<gtStackAction>
| targetContext actionLabel |
aPhlowActionContext currentDebuggingSession
findLimitedFullActiveContextForMethod: ZnClient>>#execute
ifFound: [ :aContext | targetContext := aContext ]
ifNone: [ ^ anAction noAction ] .
actionLabel := 'Increase the timeout in the HTTP client and retry the request'.
^ anAction dropdown
label: 'Retry';
icon: BrGlamorousVectorIcons refresh ;
priority: 50;
id: #'gtConnectionTimedOut-retry';
tooltip: actionLabel;
preferredExtent: 650@350;
content: [ :aSourceButton |
| contentElement |
contentElement := GtZnClientConnectionTimedOutRetryElement
forZnClient: targetContext receiver
andDebugger: aPhlowActionContext currentDebugger
fromSourceElement: aSourceButton.
contentElement
actionLabel: actionLabel;
retryAction: [ :newCount :currentDebugger |
self
gtActionPerformRetryUsing: currentDebugger
withNewTimeout: newCount].
contentElement ]
Continue:: provides a way to continue waiting for data to be read or written by setting a new timeout.
Continuing waiting it done by restarting and resuming execution from the method ZdcAbstractSocketStream>>#socketWaitForData
socketWaitForData
^ socket waitForDataFor: self timeout
.
Implemented by the method ConnectionTimedOut>>#gtZincActionContinueWaitingFor:inContext:
gtZincActionContinueWaitingFor: anAction inContext: aPhlowActionContext
<gtStackAction>
| targetContext actionLabel |
(aPhlowActionContext currentDebuggingSession
hasLimitedFullActiveContextForMethod: ZnClient>>#execute)
ifFalse: [ ^ anAction noAction ].
aPhlowActionContext currentDebuggingSession
findLimitedFullActiveContextForMethod: ZdcAbstractSocketStream>>#socketWaitForData
ifFound: [ :aContext | targetContext := aContext ]
ifNone: [ ^ anAction noAction ] .
actionLabel := 'Continue waiting for the HTTP response'.
^ anAction dropdown
label: 'Continue';
icon: BrGlamorousVectorIcons play ;
priority: 50;
id: #'gtConnectionTimedOut-wait';
tooltip: actionLabel;
preferredExtent: 650@350;
content: [ :aSourceButton |
| contentElement |
contentElement := GtZnClientConnectionTimedOutRetryElement
forSocketStream: targetContext receiver
andDebugger: aPhlowActionContext currentDebugger
fromSourceElement: aSourceButton.
contentElement
actionLabel: actionLabel;
retryAction: [ :newCount :currentDebugger |
self
gtActionContinueWaitingUsing: currentDebugger
withNewTimeout: newCount].
contentElement ]
.
Network errors leading to retries
Zinc defined in the method ZnClient>>#retryExceptionSet
retryExceptionSet
^ NetworkError, ZnParseError, ZnCharacterEncodingError, ZnUnknownScheme, ZnPortNotANumber
a list of exceptions that are handled by doing a retry. When the maximum number of retries is reached, the last error is signaled.
These exceptions (except ConnectionTimedOut, which is handled above) during a Zinc request have a debugging action:
Retry: provides a way to increase the number of retries 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.
Retrying it done by restarting and resuming execution from the method ZnClient>>#execute
execute
"Execute the currently set up request to generate a response.
Return the #contents of the response, if any."
^ self withDynamicVariablesDo: [
| result |
self prepareRequest.
result := self executeWithTimeout.
self prepareNextRequest.
result ]
.
Implemented by the debugging action GtZnClientFailedRequestRetryDebugAction
DebugAction subclass: #GtZnClientFailedRequestRetryDebugAction
instanceVariableNames: ''
classVariableNames: ''
package: 'GToolkit-DebuggerExtensions-Zinc'
.