SocketErrorNotification.st
author Claus Gittinger <cg@exept.de>
Sat, 02 May 2020 21:40:13 +0200
changeset 5476 7355a4b11cb6
parent 4569 9bc9566e899d
permissions -rw-r--r--
#FEATURE by cg class: Socket class added: #newTCPclientToHost:port:domain:domainOrder:withTimeout: changed: #newTCPclientToHost:port:domain:withTimeout:

"{ Package: 'stx:libbasic2' }"

"{ NameSpace: Smalltalk }"

Notification subclass:#SocketErrorNotification
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Kernel-Exceptions-Errors'
!

!SocketErrorNotification class methodsFor:'documentation'!

documentation
"
    This notification is raised, when an error in a Socket operation is detected.
    It is used to have a soft transition from old code checking for false
    to code catching exceptions.

    [author:]
        Stefan Vogel

    [instance variables:]
        parameter    - the OSError containing the error number and error string.

    [class variables:]

    [see also:]

"
! !

!SocketErrorNotification methodsFor:'accessing'!

errorCategory
    "return the generi OS independent error category.
     return #unknown, if this is not an OS error"

    |holder|

    holder := self osErrorHolder.
    holder isNil ifTrue:[
        ^ #unknown
    ].
    ^ holder errorCategory.

    "Created: / 19-01-2018 / 13:41:19 / stefan"
!

errorCode
    "return the generi OS independent error category.
     return nil, if this is not an OS error"

    |holder|

    holder := self osErrorHolder.
    holder isNil ifTrue:[
        ^ nil
    ].
    ^ holder errorCode.

    "Created: / 19-01-2018 / 13:42:07 / stefan"
!

osErrorHolder
    ^ parameter

    "Created: / 19-01-2018 / 13:39:28 / stefan"
!

osErrorString
    "return the generi OS independent error category.
     return nil, if this is not an OS error"

    |holder|

    holder := self osErrorHolder.
    holder isNil ifTrue:[
        ^ nil
    ].
    ^ holder errorString.

    "Created: / 19-01-2018 / 15:42:17 / stefan"
! !

!SocketErrorNotification methodsFor:'printing & storing'!

description
    "lazy initialization - the text is not needed for caught exceptions"

    messageText isNil ifTrue:[
	self initializeMessageText
    ].
    ^ super description
!

initializeMessageText
    "for lazy initialization - the text is not needed for caught exceptions"

    self osErrorHolder notNil ifTrue:[
        messageText := ' : ' , self osErrorHolder errorString.
    ].

    "Modified (format): / 19-01-2018 / 13:58:29 / stefan"
!

messageText
    "lazy initialization - the text is not needed for caught exceptions"

    messageText isNil ifTrue:[
	self initializeMessageText
    ].
    ^ messageText
! !

!SocketErrorNotification class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
! !