Exceptions


Description of exception handling before version 0.90 of VBOrb.

cOrbException

cOrbException is the class to handle all kind of exceptions. User exeptions and system exeptions are set by putting the exception in the kind property of cOrbException.

User Exceptions

Sending an user exception

If writing a server in VB user exceptions will be thrown by the following code. The execute method of the skeleton code test if a user exception is set and send them over the wire to the client.

   Dim oMyException As New c_MyException
   Call oEx.setMe("MyException occured", Kind:=oMyException)
   GoTo ExHandler

Receiving an user exception

The invokeReq method of class cOrbObjRef receive the user exception and put them in a normal exception. Here is the code which can be used by the client to handle user exceptions.

   Call remoteObject.method(oEx)
   If oEx.isSet Then
      Select Case TypeName(oEx.Kind)
      Case "c_MyException"
         Dim oMyException as c_MyException
         Set oMyException = oEx.Kind
         call oEx.unSet()
         'Do something with oMyException...
         Exit Function
      Case Else
         GoTo ExHandler ' Other exception
      End Select
   End If

System Exceptions

System exceptions are handle similar as user exceptions.

Server Side

If writing a server in VB system exceptions will be thrown by the following code. The readExecuteWrite method in class cOrbImpl test if a system exception is set and send them over the wire to the client.

   Dim oSystemEx As New cOrbSystemException
   Call oSystemEx.setBADPARAM(1, oSystemEx.CompletedNO)
   Call oEx.setMe(oSystemEx.Description, Kind:=oSystemEx)
   GoTo ExHandler

Client Side

The invokeReq method of class cOrbObjRef receive the system exception and put them in a normal exception. Here is the code which can be used by the client to handle system exceptions.

   Call remoteObject.method(oEx)
   If oEx.isSet Then
      Select Case TypeName(oEx.Kind)
      Case "cOrbSystemException"
         Dim oSystemEx as cOrbSystemException
         Set oSystemEx = oEx.Kind
         call oEx.unSet()
         'Do something with oSystemEx...
         Exit Function
      Case Else
         GoTo ExHandler ' Other exception
      End Select
   End If