home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / pyhtmldoc / e / exceptions < prev   
Text File  |  1996-11-14  |  1KB  |  26 lines

  1. <TITLE>Exceptions -- Python library reference</TITLE>
  2. Next: <A HREF="../s/supporting_floating_point_data" TYPE="Next">Supporting Floating Point Data</A>  
  3. Prev: <A HREF="../u/unpacker_objects" TYPE="Prev">Unpacker Objects</A>  
  4. Up: <A HREF="../x/xdrlib" TYPE="Up">xdrlib</A>  
  5. Top: <A HREF="../t/top" TYPE="Top">Top</A>  
  6. <H2>10.16.3. Exceptions</H2>
  7. Exceptions in this module are coded as class instances:
  8. <P>
  9. <DL><DT><B>Error</B> -- exception of module xdrlib<DD>
  10. The base exception class.  <CODE>Error</CODE> has a single public data
  11. member <CODE>msg</CODE> containing the description of the error.
  12. </DL>
  13. <DL><DT><B>ConversionError</B> -- exception of module xdrlib<DD>
  14. Class derived from <CODE>Error</CODE>.  Contains no additional instance
  15. variables.
  16. </DL>
  17. Here is an example of how you would catch one of these exceptions:
  18. <P>
  19. <UL COMPACT><CODE>import xdrlib<P>
  20. p = xdrlib.Packer()<P>
  21. try:<P>
  22.     p.pack_double(8.01)<P>
  23. except xdrlib.ConversionError, instance:<P>
  24.     print 'packing the double failed:', instance.msg<P>
  25. </CODE></UL>
  26.