TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: Peter Garner
date: 1996-11-05 22:44:32
subject: OCL IException Classes

Hi all,

  We are having a problem using the IBM exception classes.  I have
summarized the odd behaviour in the following code.  I have run this
snippet using the following 2 compile commands :

    Compile to run with the C/C++ Runtime DLLs
    icc /Gd+ /Gm+ /Tdp iexcp.cpp   CPPOM30I.LIB   

    Compile to run with the C/C++ Runtime Libraries
    icc /Gd- /Gm+ /Tdp iexcp.cpp   CPPOM30.LIB


  Location information does not get printed no matter what.  I am sure I
am missing something in the documentation, but I cannot seem to get
Location information from the caught object.

  Secondly running this program compiled for use with the C/C++ Runtime
DLLs on our system produces the output :

      IException Caught!
      Exception Type : IAccessError, Error ID = 1
      MAIN  EXCEPTION


  Running this program compiled for use with the C/C++ Runtime Libraries
on our system produces the output :


      IAccessError exception thrown.
         Location information is unavailable.
         Error Id is 1
         Error Code group is IBM Class Library
         Exception text is:
            MAIN  EXCEPTION
      IException Caught!
      Exception Type : IAccessError, Error ID = 1
      MAIN  EXCEPTION
  

  Why is this?  Why can't I get location information and why do I get
the extra information with the Library compile?  I assume that what I am 
seeing in the latter case is trace enabled.

  In addition, unless I include , I get numerous linker errors
saying that the member methods of IException and IAccessError cannot be
resolved!  Any help anyone can give me is greatly appreciated.


/*=====================================================================*/
# include 
# include 
# include   //  Won't link at all without this!



ostream & operator << ( ostream & rostrm , IException & riexcp ) ;


int main ()
{
  try
  {
    ITHROW ( IAccessError ( "MAIN  EXCEPTION" , 1 ) ) ;

  } /* endtry */
  catch ( IException & riexcp )
  {
    cerr  << "IException Caught!\n" ;
    cerr  << riexcp ;

  } /* endcatch ( IException & ) */

  return  0 ;

} /* int main () */



ostream & operator << ( ostream & rostrm , IException & riexp )
{
  unsigned long               ul  ;
  unsigned long               ulCount = riexp.textCount () ;

  const IExceptionLocation  * cpiexcploc = 0               ;

  rostrm  << "Exception Type : "  << riexp.name     ()
          << ", Error ID = "      << riexp.errorId 
() << '\n' ;
    
  for ( ul = 0 ; ul < ulCount ; ul++ )
  {
    rostrm << riexp.text ( ul ) << '\n' ;

  } /* endfor */

  ulCount = riexp.locationCount () ;

  for ( ul = 0 ; ul < ulCount ; ul++ )
  {
    cpiexcploc = riexp.locationAtIndex ( ul ) ;

    rostrm  
functionName () 
            
fileName     () 
            
lineNumber   () << '\n' ;

  } /* endfor */

  return  rostrm  << endl ;

} /* ostream & operator << ( ostream & rostrm , IException
& riexp ) */
/*=====================================================================*/


--- Maximus/2 2.02
* Origin: OS/2 Shareware BBS, telnet://bbs.os2bbs.com (1:109/347)
SEEN-BY: 50/99 270/101 620/243 625/160 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 624 628 713/317 800/1
@PATH: 109/347 18 7 396/1 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.