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.

133 lines
3.7 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. //
  3. // abstract pure virtual base class for all Error objects,
  4. // defining the services all Error objects must supply.
  5. //
  6. // 8-14-97 sburns
  7. #ifndef ERROR_HPP_INCLUDED
  8. #define ERROR_HPP_INCLUDED
  9. // this really could be anything. Someday I might actually use this
  10. // HelpContext stuff.
  11. typedef LONG_PTR HelpContext;
  12. // class Error is a pure virtual base class used to encapsulate error
  13. // information in to a single unit which may participate in exception
  14. // handling or be passed between functions in lieu of a simple error
  15. // code.
  16. //
  17. // It is the base class of a taxonomy of Error classes. Rather than
  18. // attempt to reuse an existing type, a new component should consider
  19. // defining a new type suitable for the semantics of that component's
  20. // function. (implementation, of course, can be re-used). Introducing
  21. // types in this fashion facilitates selection of error handlers in a
  22. // try..catch blocks, beyond the OO-wholesomeness of the practice.
  23. //
  24. // Another characteristic of this abstraction is the ability to
  25. // support cross-locale exception propagation. This is the problem
  26. // where an exception is thrown in a system which is in a different
  27. // locale than the system catching the exception. A remoteable
  28. // implementation of this class could account for crossing locales (by
  29. // utilizing locale-independent representations of the error, and
  30. // providing translation capabilities for each supported locale, for
  31. // instance).
  32. //
  33. // At some point in the future, this class could subclass
  34. // std::exception in some useful way, when the semantics of the C++
  35. // exception hierarchy finally stabilize in practice.
  36. class Error
  37. {
  38. public:
  39. // // Error::Details expresses the truly gritty bits of an occurrence
  40. // // of an error, which user interfaces may or may not wish to expose
  41. // // to the end user.
  42. //
  43. // class Details
  44. // {
  45. // public:
  46. //
  47. // // Constructs an instance.
  48. // //
  49. // // body - The gritty details text.
  50. // //
  51. // // fileName - The source file of the code that produced the
  52. // // error
  53. // //
  54. // // lineNumber - The location within the source file of the code
  55. // // that produced the error.
  56. //
  57. // Details(
  58. // const String& body,
  59. // const String& fileName,
  60. // unsigned lineNumber);
  61. //
  62. // // default dtor, copy ctor, op= used. This class is cheap to
  63. // // copy
  64. //
  65. // // Returns the body text with which the instance was created.
  66. //
  67. // String
  68. // GetBody() const;
  69. //
  70. // // Returns the file name with which the instance was created.
  71. //
  72. // String
  73. // GetFileName() const;
  74. //
  75. // // Returns the line number with which the instance was created.
  76. //
  77. // unsigned
  78. // GetLineNumber() const;
  79. //
  80. // private:
  81. //
  82. // String body_;
  83. // String file;
  84. // int line;
  85. // };
  86. // a pure virtual dtor ensures abstractness
  87. virtual ~Error() = 0;
  88. // // return a Details object containing additional trivia, such as
  89. // // context information.
  90. //
  91. // virtual
  92. // Details
  93. // GetDetails() const = 0;
  94. // return the HelpContext that will point the user to assistance
  95. // in deciphering the error message and details.
  96. virtual
  97. HelpContext
  98. GetHelpContext() const = 0;
  99. // return the human readable error message.
  100. virtual
  101. String
  102. GetMessage() const = 0;
  103. // return a 1-line summary: The essence of the error, suitable for
  104. // use as the title of a reporting dialog, for instance.
  105. virtual
  106. String
  107. GetSummary() const = 0;
  108. };
  109. #endif // ERROR_HPP_INCLUDED