'From etoys2.3 of 28 November 2007 [latest update: #1853] on 20 December 2007 at 10:07:30 am'! Error subclass: #EtoysError instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'System-Exceptions Kernel'! UnhandledError subclass: #EtoysUnhandledError instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'System-Exceptions Kernel'! !Object methodsFor: 'error handling' stamp: 'yo 12/19/2007 19:00'! eToysError: aString "Throw a generic Error exception." ^EtoysError new signal: aString! ! !Debugger methodsFor: 'initialize' stamp: 'yo 12/19/2007 20:17'! preDebugNotifierContentsFrom: messageString | first second msg | ^ Preferences eToyFriendly ifFalse: [messageString] ifTrue: [ msg _ messageString. msg ifNil: [msg _ '']. first _ second _ 0. first _ msg indexOf: $\ ifAbsent: [0]. first > 0 ifTrue: [second _ msg indexOf: $\ startingAt: first + 1 ifAbsent: [0]]. (first > 0 and: [second > 0]) ifTrue: [ 'An error has occurred in\{3} of {2}.\Fix your script(s), hit ''Abandon'' and try again.' translated withCRs format: {msg copyFrom: 1 to: first - 1. msg copyFrom: first + 1 to: second - 1. msg copyFrom: second + 1 to: msg size} ] ifFalse: [ 'An error has occurred; you should probably just hit ''abandon''. Sorry!!' translated ] ] ! ! !EtoysError methodsFor: 'all' stamp: 'yo 12/19/2007 20:14'! defaultAction "See Error>>defaultAction for comments." EtoysUnhandledError signalForException: self! ! !EtoysError methodsFor: 'all' stamp: 'yo 12/19/2007 19:14'! description "Return a textual description of the exception." | desc mt | desc := self class name asString. ^(mt := self messageText) == nil ifTrue: [desc] ifFalse: [mt copyUpTo: $\]! ! !EtoysUnhandledError methodsFor: 'priv handling' stamp: 'yo 12/19/2007 19:00'! devDefaultAction Processor activeProcess debug: exception signalerContext title: exception description full: false contents: exception messageText ! ! !Float methodsFor: 'arithmetic' stamp: 'yo 12/19/2007 19:21'! / aNumber "Primitive. Answer the result of dividing receiver by aNumber. Fail if the argument is not a Float. Essential. See Object documentation whatIsAPrimitive." aNumber isZero ifTrue: [^ Preferences eToyFriendly ifTrue: [ScriptingSystem reportToUser: 'division by zero'] ifFalse: [(ZeroDivide dividend: self) signal]]. ^ aNumber adaptToFloat: self andSend: #/! ! !Process methodsFor: 'debugging' stamp: 'yo 12/19/2007 18:59'! debug: context title: title full: bool contents: contents "Open debugger on self with context shown on top" | topCtxt | topCtxt _ self isActiveProcess ifTrue: [thisContext] ifFalse: [self suspendedContext]. (topCtxt hasContext: context) ifFalse: [^ self error: 'context not in process']. Debugger openOn: self context: context label: title contents: contents fullView: bool. ! ! !ScriptInstantiation methodsFor: 'status control' stamp: 'yo 12/19/2007 20:16'! resetTo: newStatus ifCurrently: aStatus "If my status *had been* aStatus, quietly reset it to newStatus, without tampering with event handlers. But get the physical display of all affected status morphs right" status == aStatus ifTrue: [status _ newStatus. self updateAllStatusMorphs]! ! !StandardScriptingSystem methodsFor: 'utilities' stamp: 'yo 12/19/2007 20:46'! reportToUser: aString "Make a message accessible to the user. " | trigger current baseTriggerer topTriggerer mclass sel topSelector | trigger _ Player compiledMethodAt: #triggerScript:. current _ thisContext. baseTriggerer _ nil. topTriggerer _ nil. [current notNil] whileTrue: [ topTriggerer ifNil: [ current receiver class isUniClass ifTrue: [ "Look for the top-most uniclass script in the call chain." sel _ current receiver class selectorAtMethod: current method setClass: [:c | mclass _ c]. mclass = current receiver class ifTrue: [ topTriggerer _ current. topSelector _ sel. ]. ]. ]. (current method = trigger and: [current class == MethodContext]) ifTrue: [ "Look for the bottom-most #triggerScript: and its selector." baseTriggerer _ current ]. current _ current sender. ]. baseTriggerer ifNotNil: [ (baseTriggerer receiver scriptInstantiationForSelector: (baseTriggerer at: 1)) resetTo: #paused ifCurrently: #ticking. ]. (topTriggerer notNil and: [topSelector notNil]) ifTrue: [ ^ self eToysError: aString, '\', topTriggerer receiver knownName, '\', topSelector. ]. self error: aString. ! ! !EtoysUnhandledError reorganize! ('priv handling' devDefaultAction) ! !EtoysError reorganize! ('all' defaultAction description) !