Exception Handling Integration with 2.5 -- version 1

Stephen Travis Pope stp at create.ucsb.edu
Mon Aug 16 16:36:22 UTC 1999


Hello all,

I made a first pass over integrating the TFEI exception handling code
with the system libraries based on the exception hierarchy we discussed
last week. I put the code (BinHexed-StuffIt and gzipped-tar files) in
the FTP directory
ftp://ftp.create.ucsb.edu/pub/Smalltalk/Squeak/goodies/ExcHandling.
Comments are invited.

Here's the basic revised hierarchy and comments on the implementation.
The minimal test/demo suite is at the end of the file.

Note that several of the exceptions are not yet implemented because they
imply VM changes (e.g., making [array at: 1.5] or [10 raisedTo: 500]
fail in the primitives) or are not appropriate on my platform (Mac)
(e.g., FileProtected).

stp


Squeak Exception Hierarchy -- Revised Proposal

Exception ('messageText' 'initialContext' 'resignalException'
'handlerContext' 'tag' )
  Error ()

"Basic errors"
    Halt
    MessageNotUnderstood ('message' )
    SubclassResponsibility
    ShouldNotImplement
    PrimitiveFailure
    UserInterrupt

"Class libraries"
    ArithmeticError
      DomainError
        ZeroDivide
        SqrtOfNegative
        LogOfZero
      RangeError -- not yet -- primitives return +-infinity
        Underflow
        Overflow
    AccessingError
      CollectionError
        NotOrderedError
        NonIntegerIndex -- not yet -- primitives round indeces
        SubscriptOutOfBounds
    NotFoundError
      IndexNotFound
        KeyNotFound
        ValueNotFound

"Files & Streams"
    FileError
      HostFileSystemError (errorCode) -- not yet
      IllegalFilename
      DirectoryNotFound -- not yet
      FileProtected -- not yet
      VolumeFull -- not yet
      FileAlreadyExists
      FileNotFound
      FileSharingViolation -- not yet
      TooManyOpenFiles -- not yet
    StreamError
      StreamAtEnd
      StreamReadError
      StreamWriteError -- not raised in standard libraries
      PositionOutOfBounds

"External" -- not yet
    APICallError()
      APICallEntryPointNotFound (entryPoint dll)
      APICallInvalidArgumentType (expectedType argumentNumber)
      APICallUnknownPrimitiveFailure
    OSSignal -- OS signal

"Notifications" -- not yet
  Notification
    Warning
    FinalizeProcessNotification
    AboutToReplaceFile (entity)
    ProcessTermination
    ProgressNotification
    UnregisteredEvent (event)


System Exception Tests

[ "Select this block for the basic test suite"

[self halt] on: Halt 
  do: [Transcript show: 'caught Halt'; cr].
[3 zork] on: MessageNotUnderstood 
  do: [Transcript show: 'caught MNU'; cr].
[(Stream basicNew) next] on: SubclassResponsibility 
  do: [Transcript show: 'caught SubclassResponsibility'; cr].
[(1 to: 5) add: 7] on: ShouldNotImplement 
  do: [Transcript show: 'caught ShouldNotImplement'; cr].
[FileDirectory default primCreateDirectory: ''] on: PrimitiveFailure 
  do: [Transcript show: 'caught PrimitiveFailure'; cr].

[1 / 0] on: ZeroDivide 
  do: [Transcript show: 'caught ZeroDivide'; cr].
[1 negated sqrt] on: SqrtOfNegative 
  do: [Transcript show: 'caught SqrtOfNegative'; cr].
"
[-1.0 ln] on: NonPositiveLog
  do: [Transcript show: 'caught NonPositiveLog'; cr] -- doesn't work
[10.0 raisedTo: 500]   -- should signal over/underflow -- prim returns
+- infinity
"
[Set new at: 1] on: NotOrderedError
  do: [Transcript show: 'caught NotOrderedError'; cr].
"
[(Array with: 1 with: 2) at: 1.5] on: NonIntegerIndex
  do: [Transcript show: 'caught NonIntegerIndex'; cr]   -- doesn't work,
primitive fixes it
"
[(Array with: 1 with: 2) at: 3] on: SubscriptOutOfBounds
  do: [Transcript show: 'caught SubscriptOutOfBounds'; cr].

[Smalltalk at: #Stephen] on: KeyNotFound
  do: [Transcript show: 'caught KeyNotFound'; cr].
[Smalltalk keyAtValue: #Stephen] on: ValueNotFound
  do: [Transcript show: 'caught ValueNotFound'; cr].

[FileStream oldFileNamed: 'notThere2'] on: FileNotFound
  do: [Transcript show: 'caught FileNotFound'; cr].
[FileStream newFileNamed: 'SqueakV2.sources'] on: FileAlreadyExists
  do: [Transcript show: 'caught FileAlreadyExists'; cr].
[FileStream fileNamed: ''] on: IllegalFilename
  do: [Transcript show: 'caught IllegalFilename'; cr].

[(ReadStream on: '1') next; next] on: StreamAtEnd
  do: [Transcript show: 'caught StreamAtEnd'; cr].
[(ReadStream on: '1') position: 2] on: PositionOutOfBounds
  do: [Transcript show: 'caught PositionOutOfBounds'; cr]]


-- 

stp
  Stephen Travis Pope -- http://www.create.ucsb.edu/~stp
  stp at create.ucsb.edu -- stp9 at cornell.edu





More information about the Squeak-dev mailing list