screrror.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. /***************************************************************************
  7. Exception blocks
  8. ***************************************************************************/
  9. class ErrHandler;
  10. struct ParseNode;
  11. class COleScript;
  12. interface IScanner;
  13. inline void FreeExcepInfo(EXCEPINFO *pei)
  14. {
  15. if (pei->bstrSource)
  16. SysFreeString(pei->bstrSource);
  17. if (pei->bstrDescription)
  18. SysFreeString(pei->bstrDescription);
  19. if (pei->bstrHelpFile)
  20. SysFreeString(pei->bstrHelpFile);
  21. memset(pei, 0, sizeof(*pei));
  22. }
  23. void CopyException (EXCEPINFO *pexcepinfoDest, const EXCEPINFO *pexcepinfoSource);
  24. BOOL FSupportsErrorInfo(IUnknown *punk, REFIID riid);
  25. HRESULT GetErrorInfo(EXCEPINFO *pexcepinfo);
  26. HRESULT MapHr(HRESULT hr, ErrorTypeEnum * errorTypeOut = nullptr);
  27. class SRCINFO;
  28. class ActiveScriptError;
  29. class ScriptException
  30. {
  31. public:
  32. long ichMin;
  33. long ichLim;
  34. EXCEPINFO ei;
  35. public:
  36. ScriptException()
  37. { memset(this, 0, sizeof(*this)); }
  38. ~ScriptException(void);
  39. public:
  40. void CopyInto(ScriptException *pse);
  41. void Free();
  42. void GetError(HRESULT *phr, EXCEPINFO *pei); // Clears error.
  43. };
  44. class CompileScriptException : public ScriptException
  45. {
  46. public:
  47. long line; // line number of error (zero based)
  48. long ichMinLine; // starting char of the line
  49. bool hasLineNumberInfo;
  50. // TODO: if the line contains \0 character the substring following \0 will not be included:
  51. BSTR bstrLine; // source line (if available)
  52. public:
  53. CompileScriptException(void) : ScriptException(), line(0), ichMinLine(0), hasLineNumberInfo(false),
  54. bstrLine(nullptr)
  55. { }
  56. ~CompileScriptException();
  57. public:
  58. void Clear();
  59. void Free();
  60. void GetError(HRESULT *phr, EXCEPINFO *pei)
  61. {
  62. ScriptException::GetError(phr, pei);
  63. Free();
  64. }
  65. HRESULT ProcessError(IScanner * pScan, HRESULT hr, ParseNode * pnodeBase);
  66. friend class ActiveScriptError;
  67. };