Configuring moldable exceptions
This page describes the Moldable Exceptions mechanism for configuring a domain-specific debugger based on exceptions.
Exception define domain-specific debuggers through dedicated configurations. Each exception inherits a default configuration from Exception>>#gtExceptionDebuggerSpecification
that they can override and configure.
Use the snippet below to view all implementation of this method
#gtDebuggingExtensionConfiguration gtImplementors
Extensions configurations are instances of GtMoldableExceptionSpecificDebuggerSpecification
. At run-time when an exception is not handled the configuration is used to instantiate a debugger of type GtMoldableExceptionDebuggingElement
that shows views and actions based on that configuration.
Next we look at various aspects that can be configured by an exception.
Debugging Views
Exceptions can define one or more views shown in the debugger. Configurations can indicate the pragma with which these methods are annotate thorugh GtMoldableExceptionSpecificDebuggerSpecification>>#debuggingViewPragmas:
. By default the pragma gtExceptionView
is used.
Use the snippet below to see all debugging views in the system
#gtExceptionView gtPragmas
Target Objects
By default the debugger looks for debugging views in the exception object. However, users can add more objects where the debugger will look for debugging views. Like this debugging views can be added to any object.
The debugging configuration has a composite target, instance of GtMoldableExceptionDebuggingViewTargets
that contains all the individual debugging targets (GtMoldableExceptionDebuggingViewsObjectTarget
) where the debugger looks for views.
The method GtMoldableExceptionDebuggerSpecification>>#addDebuggingTargetFor:
provides the entry point for adding a new target for a given object.
By default, the exception is a target for looking for views. We can remove it using GtMoldableExceptionDebuggerSpecification>>#withoutDebuggingExceptionTarget
.
Enabling/disabling debugging extension
Even if an exception defines a debugging extension, depending on the state of the exception we might not want to show the domain-specific debugger for that exception.
We can control when the debugging extension is active by using GtMoldableExceptionSpecificDebuggerSpecification>>#enableWhen:
. This takes as a parameter a block, and the extension is enabled when the block returns true
.
Global Debugging Actions
Exceptions can add global debugging actions in the toolbar of the debugger. Global debugging actions are subclasses of DebugAction
.
An exception can indicate the pragma with which these classes are annotated using GtMoldableExceptionDebuggerSpecification>>#globalDebuggingActionPragmas:
.