requires: {#Condition. #Collection}. provides: {#ProtocolError. #MethodNotFound. #OverrideThis. #ShouldNotImplement. #SlotError. #SlotNotFound. #SlotTypeError}. conditions addPrototype: #SlotError derivedFrom: {Error}. "Errors related to slot manipulations." SlotError addSlot: #object. SlotError addSlot: #slotName. conditions addPrototype: #SlotNotFound derivedFrom: {SlotError}. obj@(Root traits) slotNotFoundNamed: name [| snf | snf: SlotNotFound new. snf object: obj. snf slotName: name. snf signal ]. snf@(SlotNotFound traits) describe [ DebugConsole ; 'The object ' ; snf object printString ; ' does not have a slot named ' ; snf slotName printString ; '.\n' ]. conditions addPrototype: #SlotTypeError derivedFrom: {SlotError}. "Results from attempting to assign a value to a slot that is incompatible with a specified type for the slot." SlotTypeError addSlot: #type. conditions addPrototype: #ProtocolError derivedFrom: {Error}. "A ProtocolError is an Error from not complying with an object's reuse protocol." conditions addPrototype: #MethodNotFound derivedFrom: {ProtocolError}. "A MethodNotFound is a ProtocolError signaled when dispatch fails." MethodNotFound addSlot: #selector. MethodNotFound addSlot: #arguments. MethodNotFound addSlot: #optionals valued: {}. selector@(Symbol traits) notFoundOn: arguments [| mnf | mnf: MethodNotFound new. mnf selector: selector. mnf arguments: arguments. mnf signal ]. selector@(Symbol traits) notFoundOn: arguments withOptionals: optionals [| mnf | mnf: MethodNotFound new. mnf selector: selector. mnf arguments: arguments. mnf optionals: optionals. mnf signal ]. mnf@(MethodNotFound traits) describe [ DebugConsole ; 'The method ' ; mnf selector printString ; ' was not found for the following arguments:\n' ; mnf arguments printString. mnf optionals isEmpty ifFalse: [DebugConsole ; '\nwith optionals:\n' ; mnf optionals printString]. DebugConsole ; '\n' ]. conditions addPrototype: #OverrideThis derivedFrom: {ProtocolError}. "An OverrideThis is an Error signaled when a method was not properly overridden." _@(OverrideThis traits) describe [ DebugConsole ; 'The method was not defined by a child object as required.\n' ]. _@lobby overrideThis [ OverrideThis signal ]. conditions addPrototype: #ShouldNotImplement derivedFrom: {ProtocolError}. "An ShouldNotImplement is an Error signaled when a method that shouldn't be defined is defined." _@(ShouldNotImplement traits) describe [ DebugConsole ; 'The method should not be implemented on a child object.\n' ]. _@lobby shouldNotImplement [ ShouldNotImplement signal ]. conditions addPrototype: #ConversionNotFound derivedFrom: {Error}. "A ConversionNotFound is an Error signaled when the use of as: is on arguments for which no reasonable conversion exists." ConversionNotFound addSlot: #source. ConversionNotFound addSlot: #target. x@(Root traits) conversionNotFoundTo: y [| newC | newC: ConversionNotFound new. newC source: x. newC target: y. newC signal ]. c@(ConversionNotFound traits) describe [ DebugConsole ; 'A suitable conversion method could not be found to convert between these two objects:\n' ; c source printString ; '\n' ; c target printString ; '\n'. ]. numerics addPrototype: #OperationError derivedFrom: {Error}. "A numeric operation error. This offers the ability to continue with some value." numerics OperationError addPrototype: #ReturnInput derivedFrom: {Restart}. numerics OperationError ReturnInput addSlot: #newValue valued: 0. "The value to return from the operation." r@(OperationError ReturnInput traits) query [ DebugConsole ; 'Select a value to return: '. r newValue: (Syntax Parser newOn: (DebugConsole reader upTo: $\n) reader) next evaluate. ]. _@(OperationError ReturnInput traits) describe [ DebugConsole ; 'Select a new value to return\n' ]. r@(OperationError ReturnInput traits) defaultHandler [ r condition return: r newValue ]. _@(OperationError traits) describe [ DebugConsole ; 'Numeric operation error.\n' ]. "[| :restart | restart condition return: restart newValue]" numerics addPrototype: #DivideByZero derivedFrom: {numerics OperationError}. "A division by zero error." DivideByZero addSlot: #dividend valued: 0. "The number which division was taken on." e@(DivideByZero traits) describe [ DebugConsole ; 'Divide by zero of ' ; e dividend print ; '.\n' ]. e@(DivideByZero traits) of: x [| result | result: e new. result dividend: x. result ]. Collection traits addPrototype: #Condition derivedFrom: {Condition}. Collection Condition addSlot: #collection. "The collection that is the subject of this condition." cond@(Collection Condition traits) newCollection: coll@(Collection traits) [| result | result: cond new. result collection: coll. result ]. cond@(Collection Condition traits) describe [ DebugConsole ; 'Collection ' ; cond collection printString ; 'signaled: ' ; cond name ; '\n'. ]. Collection traits addPrototype: #ElementNotFound derivedFrom: {Collection Condition. Error}. Collection ElementNotFound addSlot: #element. enf@(Collection ElementNotFound traits) describe [ DebugConsole ; enf collection printString ; 'does not contain: ' ; enf element printString ; '\n'. ]. element elementNotFoundOn: c@(Collection traits) [| enf | enf: (c ElementNotFound newCollection: c). enf element: element. enf signal ]. Collection traits addPrototype: #IsEmpty derivedFrom: {Collection Condition. Error}. c@(Collection traits) emptyCheck [ c isEmpty ifTrue: [(c IsEmpty newCollection: c) signal] ]. Mapping traits addPrototype: #KeyNotFound derivedFrom: {Collection Condition. Error}. "A key which was not found in the specified collection." Mapping KeyNotFound addSlot: #key. knf@(Mapping KeyNotFound traits) describe [ DebugConsole ; knf key printString ; 'is not a key in ' ; knf collection printString ; '\n'. ]. key keyNotFoundOn: m@(Mapping traits) [| knf | knf: (m KeyNotFound newCollection: m). knf key: key. knf signal ].