Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1997
  6. //
  7. // File: gmexcept.h
  8. //
  9. //--------------------------------------------------------------------------
  10. //
  11. // gmexcept.h: Graphical Model Exception handling
  12. //
  13. #ifndef _GMEXCEPT_H_
  14. #define _GMEXCEPT_H_
  15. #include <assert.h>
  16. ////////////////////////////////////////////////////////////////
  17. // Exception Handling
  18. //
  19. // Exception error code
  20. ////////////////////////////////////////////////////////////////
  21. enum ECGM
  22. {
  23. EC_OK, // No error
  24. EC_WARN_MIN = 100, // Lowest warning value
  25. EC_ERR_MIN = 10000, // Lowest error value
  26. // Include the standard translatable errors
  27. #include "errordef.h"
  28. EC_USER_MIN = 20000 // Lowest user-definable error
  29. };
  30. // Exception class, using STL class "exception".
  31. // An "__exString" is just a char *.
  32. // class "GMException": graphical model exception
  33. class GMException : public exception
  34. {
  35. public:
  36. GMException( ECGM ec)
  37. : _ec(ec)
  38. {}
  39. GMException(ECGM ec, const __exString& exs)
  40. : exception(exs),
  41. _ec(ec)
  42. {}
  43. GMException(ECGM ec, const exception& excp)
  44. : exception(excp),
  45. _ec(ec)
  46. {}
  47. ECGM Ec () const { return _ec ; }
  48. protected:
  49. ECGM _ec;
  50. };
  51. // Exception subclass for assertion operations, such as "not implemented"
  52. // or "internal error". Can be used in place of any GMException.
  53. // If debug build, assertion will occur during exception processing.
  54. class GMExceptionAssert : public GMException
  55. {
  56. public:
  57. GMExceptionAssert(ECGM ec, const __exString& exs, SZC szcFile, unsigned iLine)
  58. : GMException(ec,exs)
  59. {
  60. #if defined(_DEBUG)
  61. _assert((void*)exs, (void*)szcFile, iLine);
  62. #endif
  63. }
  64. };
  65. #define ASSERT_THROW(expr,ec,exs) { if ( !(expr) ) THROW_ASSERT(ec,exs) ; }
  66. #define THROW_ASSERT(ec,exs) throw GMExceptionAssert(ec,exs,__FILE__,__LINE__)
  67. extern VOID NYI();
  68. #endif // _GMEXCEPT_H_