home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / classlib / desaware / dwerrors.bas < prev    next >
Encoding:
BASIC Source File  |  1996-02-17  |  1.9 KB  |  63 lines

  1. Attribute VB_Name = "dwErrors"
  2. ' Desaware API Toolkit object library
  3. ' Copyright (c) 1996 by Desaware Inc.
  4. ' All rights reserved
  5.  
  6. Option Explicit
  7.  
  8. #If Win32 Then
  9. Public Declare Function GetLastError& Lib "kernel32" ()
  10. #End If
  11.  
  12. ' List of errors
  13. ' Errors over 30000 have vbObjectError added
  14. ' others are VB errors
  15. Public Const DWERR_APIRESULT = 30000
  16. Public Const DWERR_UNINITIALIZED = 30001
  17. Public Const DWERR_NODCAVAILABLE = 30002
  18. Public Const DWERR_ISMETAFILEDC = 30003
  19. Public Const DWERR_NOTMETAFILEDC = 30004
  20. Public Const DWERR_NOTINWIN16 = 30005
  21. Public Const DWERR_INVALIDPARAMETER = 30006
  22. Public Const DWERR_COUNTMISMATCH = 30007
  23.  
  24.  
  25. Public Sub RaiseError(ByVal errnum%, classname$)
  26.     Dim desc$
  27.     
  28.     If errnum < 30000 Then
  29.         Err.Raise errnum, classname
  30.     Else
  31.         Err.Raise vbObjectError + errnum, classname, GetErrorDesc(errnum)
  32.    End If
  33. End Sub
  34.  
  35. ' Return description of class error >= 30000
  36. Private Function GetErrorDesc(ByVal errnum)
  37.     Dim desc$
  38.     If errnum < 30000 Then Exit Function
  39.     
  40.  
  41.     Select Case errnum
  42.         Case DWERR_APIRESULT
  43.             desc$ = "API Result error"
  44.         Case DWERR_UNINITIALIZED
  45.             desc$ = "Object is uninitialized"
  46.         Case DWERR_NODCAVAILABLE
  47.             desc$ = "Device Context is unavailable"
  48.         Case DWERR_NOTMETAFILEDC
  49.             desc$ = "This Device Context is not a Metafile Device Context, so this procedure does not apply to it"
  50.         Case DWERR_ISMETAFILEDC
  51.             desc$ = "This Device Context is a Metafile Device Context, so this procedure does not apply to it"
  52.         Case DWERR_NOTINWIN16
  53.             desc$ = "This function does not exist in 16-bit Windows."
  54.         Case DWERR_INVALIDPARAMETER
  55.             desc$ = "Invalid function parameter"
  56.         Case DWERR_COUNTMISMATCH
  57.             desc$ = "Counts of different collections do not match"
  58.     End Select
  59.     
  60.     GetErrorDesc = desc$
  61. End Function
  62.  
  63.