requires: {#Method. #ExtensibleSequence}. provides: {#Condition. #Error. #Warning. #Restart. #Abort}. "WARNING: This is all speculative and depends on bootstrap details which are still forthcoming." prototypes addDelegate: #conditions valued: Namespace clone. conditions addSlot: #ErrorOutput valued: ConsoleOutput. "The stream to which Error messages are sent. This should be StdErr and overridable." conditions addSlot: #Condition valued: Cloneable derive. "A situation which is not handled in normal program logic, and may require investigative or other special handling." Condition addSlot: #handlers valued: ExtensibleSequence derive. "The ordered group of handlers for the condition." c@(Condition traits) defaultHandler "Do nothing, and return nothing by default." [Nil]. c@(Condition traits) isRestartAvailable "Answer whether there is an available Restart for the Condition." [ ]. m@(Method traits) signal: c@(Condition traits) "Signalling a Condition." [ ]. m@(Method traits) on: c@(Condition traits) do: block "This is Smalltalk's main handler protocol carried over, usually for backing out of a process." [ ]. m@(Method traits) handlersDo: block "Applies the block to all of the active handlers, beginning with the most- recently established." "TODO: Method should be Activation in the dispatch." [ ]. conditions addSlot: #Restart valued: Condition derive. "A Restart is a Condition which is signaled by another Condition for the purpose of handling it." Restart addSlot: #test valued: [| :condition | True]. "a Block that returns true if this handler applies to this condition. The default is a function that always returns true." r@(Restart traits) appliesTo: c@(Condition traits) "Answers whether the Restart applies to the Condition. The default is to use the test slot." "TODO: refactor the slot into this method?" [ r test value: c ]. r@(Restart traits) defaultHandler [ error: 'No handler for this Restart.' ]. conditions addSlot: #Abort valued: Restart derive. "An Abort is a Restart which exits the computation, unwinding the stack." Abort addSlot: #description valued: ''. m@(Method traits) abort [ ]. conditions addSlot: #Warning valued: Condition derive. "Warnings are Conditions which should generate notifications, but do not need to be raised for handling, i.e. no action needs to be taken." m@(Method traits) warn: message [ Warning newWith: message ]. conditions addSlot: #SimpleWarning valued: Warning derive. "A SimpleWarning is a Warning." conditions addSlot: #StyleWarning valued: SimpleWarning derive. "A StyleWarning is a Warning that certain conventions set up by the library author have not been followed, which could lead to problems." m@(Method traits) deprecated [ StyleWarning newWith: 'This method has been deprecated.' ]. conditions addSlot: #BreakPoint valued: SimpleWarning derive. "A BreakPoint is a SimpleWarning raised when instrumenting code for debugging from a particular place in the code." m@(Method traits) break [ BreakPoint new ]. conditions addSlot: #SeriousCondition valued: Condition derive. "A SeriousCondition is a Condition that requires handling, but is not a semantic Error of the program. Rather, it's due to some incidental or pragmatic consideration." c@(SeriousCondition traits) defaultHandler "Just raise a debugger if no handler is provided." [ c invokeDebugger ]. conditions addSlot: #Error valued: SeriousCondition derive. "An Error is a SeriousCondition which involves some misstep in program logic, and raises the need for handlers." m@(Method traits) error: message [ Error newWith: message ]. m@(Method traits) methodNotFound [ Error newWith: 'This method was not found for the arguments.' ]. m@(Method traits) overrideThis [ Error newWith: 'The method was not defined by a child object as required.' ].