home *** CD-ROM | disk | FTP | other *** search
/ One Click 11 / OneClick11.iso / Bancos de Dados / Conversao / Mysql2Excel / Setup.exe / Mysql2Excel.exe / win32com / server / exception.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2003-06-23  |  3.7 KB  |  100 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.2)
  3.  
  4. '''Exception Handling
  5.  
  6.  Exceptions
  7.  
  8. \t To better support COM exceptions, the framework allows for an instance to be
  9. \t raised.  This instance may have a certain number of known attributes, which are
  10. \t translated into COM exception details.
  11. \t
  12. \t This means, for example, that Python could raise a COM exception that includes details
  13. \t on a Help file and location, and a description for the user.
  14. \t
  15. \t This module provides a class which provides the necessary attributes.
  16.  
  17. '''
  18. import sys
  19. import pythoncom
  20.  
  21. class COMException(pythoncom.com_error):
  22.     '''An Exception object that is understood by the framework.
  23. \t
  24. \tIf the framework is presented with an exception of type class,
  25. \tit looks for certain known attributes on this class to provide rich
  26. \terror information to the caller.
  27.  
  28. \tIt should be noted that the framework supports providing this error
  29. \tinformation via COM Exceptions, or via the ISupportErrorInfo interface.
  30.  
  31. \tBy using this class, you automatically provide rich error information to the
  32. \tserver.
  33. \t'''
  34.     
  35.     def __init__(self, description = None, scode = None, source = None, helpfile = None, helpContext = None, desc = None, hresult = None):
  36.         '''Initialize an exception
  37. \t\t**Params**
  38.  
  39. \t\tdescription -- A string description for the exception.
  40. \t\tscode -- An integer scode to be returned to the server, if necessary.
  41. \t\tThe pythoncom framework defaults this to be DISP_E_EXCEPTION if not specified otherwise.
  42. \t\tsource -- A string which identifies the source of the error.
  43. \t\thelpfile -- A string which points to a help file which contains details on the error.
  44. \t\thelpContext -- An integer context in the help file.
  45. \t\tdesc -- A short-cut for description.
  46. \t\thresult -- A short-cut for scode.
  47. \t\t'''
  48.         if not scode:
  49.             pass
  50.         scode = hresult
  51.         if scode and scode != 1:
  52.             if scode >= -32768 and scode < 32768:
  53.                 scode = -2147024896 | scode & 65535
  54.             
  55.         
  56.         self.scode = scode
  57.         if not description:
  58.             pass
  59.         self.description = desc
  60.         if scode == 1 and not (self.description):
  61.             self.description = 'S_FALSE'
  62.         elif scode and not (self.description):
  63.             self.description = pythoncom.GetScodeString(scode)
  64.         
  65.         self.source = source
  66.         self.helpfile = helpfile
  67.         self.helpcontext = helpContext
  68.         pythoncom.com_error.__init__(self, scode, self.description, None, -1)
  69.  
  70.     
  71.     def __repr__(self):
  72.         return '<COM Exception - scode=%s, desc=%s>' % (self.scode, self.description)
  73.  
  74.  
  75. Exception = COMException
  76.  
  77. def IsCOMException(t = None):
  78.     if t is None:
  79.         t = sys.exc_info()[0]
  80.     
  81.     
  82.     try:
  83.         return issubclass(t, pythoncom.com_error)
  84.     except TypeError:
  85.         return t is pythoncon.com_error
  86.  
  87.  
  88.  
  89. def IsCOMServerException(t = None):
  90.     if t is None:
  91.         t = sys.exc_info()[0]
  92.     
  93.     
  94.     try:
  95.         return issubclass(t, COMException)
  96.     except TypeError:
  97.         return 0
  98.  
  99.  
  100.