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.

108 lines
3.1 KiB

  1. //
  2. // MODULE: BaseException.CPP
  3. //
  4. // PURPOSE: standard exception handling classes
  5. //
  6. // COMPANY: Saltmine Creative, Inc. (206)-284-7511 [email protected]
  7. //
  8. // AUTHOR: Randy Biley
  9. //
  10. // ORIGINAL DATE: 9-24-98
  11. //
  12. // NOTES:
  13. //
  14. // Version Date By Comments
  15. //--------------------------------------------------------------------
  16. // V3.0 09-24-98 RAB
  17. //
  18. #include "stdafx.h"
  19. #include "BaseException.h"
  20. #include "fileread.h"
  21. #include "CharConv.h"
  22. ////////////////////////////////////////////////////////////////////////////////////
  23. // CBuildSrcFileLinenoStr
  24. ////////////////////////////////////////////////////////////////////////////////////
  25. // srcFile is LPCSTR rather than LPCTSTR because __FILE__ is char[35]
  26. CBuildSrcFileLinenoStr::CBuildSrcFileLinenoStr( LPCSTR srcFile, int srcLineNo )
  27. {
  28. // Reduce the source file name down the name and extension if possible.
  29. CString str;
  30. CString tmp= CAbstractFileReader::GetJustName( CCharConversion::ConvertACharToString(srcFile, str) );
  31. CString strLineNo;
  32. strLineNo.Format( _T("-L%d"), srcLineNo );
  33. m_strFileLine= tmp + strLineNo;
  34. }
  35. CString CBuildSrcFileLinenoStr::GetSrcFileLineStr() const
  36. {
  37. // Return string that contains the source file name and the line number.
  38. return m_strFileLine;
  39. }
  40. ////////////////////////////////////////////////////////////////////////////////////
  41. // CBaseException
  42. ////////////////////////////////////////////////////////////////////////////////////
  43. // srcFile is LPCSTR rather than LPCTSTR because __FILE__ is char[35]
  44. CBaseException::CBaseException( LPCSTR srcFile, int srcLineNo )
  45. {
  46. CBuildSrcFileLinenoStr str( srcFile, srcLineNo );
  47. m_strFileLine= str.GetSrcFileLineStr();
  48. }
  49. CString CBaseException::GetSrcFileLineStr() const
  50. {
  51. // Return string that contains the source file name and the line number.
  52. return m_strFileLine;
  53. }
  54. ////////////////////////////////////////////////////////////////////////////////////
  55. // CGeneralException
  56. ////////////////////////////////////////////////////////////////////////////////////
  57. // srcFile is LPCSTR rather than LPCTSTR because __FILE__ is char[35]
  58. CGeneralException::CGeneralException( LPCSTR srcFile, int srcLineNo,
  59. LPCTSTR strErrMsg, DWORD nErrCode )
  60. : CBaseException( srcFile, srcLineNo ),
  61. m_strErrMsg( strErrMsg ),
  62. m_nErrCode( nErrCode )
  63. {
  64. }
  65. DWORD CGeneralException::GetErrorCode() const
  66. {
  67. return m_nErrCode;
  68. }
  69. CString CGeneralException::GetErrorMsg() const
  70. {
  71. return m_strErrMsg;
  72. }
  73. ////////////////////////////////////////////////////////////////////////////////////
  74. // CGenSysException
  75. ////////////////////////////////////////////////////////////////////////////////////
  76. // srcFile is LPCSTR rather than LPCTSTR because __FILE__ is char[35]
  77. CGenSysException::CGenSysException( LPCSTR srcFile, int srcLineNo,
  78. LPCTSTR strErrMsg, DWORD nErrCode )
  79. : CGeneralException( srcFile, srcLineNo, strErrMsg, nErrCode )
  80. {
  81. // Format the last system error code as a string.
  82. m_strSystemErr.Format( _T("%lu"), ::GetLastError() );
  83. }
  84. CString CGenSysException::GetSystemErrStr() const
  85. {
  86. return m_strSystemErr;
  87. }
  88. //
  89. // EOF.
  90. //