screrror.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 ParseNode;
  10. class COleScript;
  11. interface IScanner;
  12. inline void FreeExcepInfo(EXCEPINFO *pei)
  13. {
  14. if (pei->bstrSource)
  15. SysFreeString(pei->bstrSource);
  16. if (pei->bstrDescription)
  17. SysFreeString(pei->bstrDescription);
  18. if (pei->bstrHelpFile)
  19. SysFreeString(pei->bstrHelpFile);
  20. memset(pei, 0, sizeof(*pei));
  21. }
  22. void CopyException (EXCEPINFO *pexcepinfoDest, const EXCEPINFO *pexcepinfoSource);
  23. HRESULT MapHr(HRESULT hr, ErrorTypeEnum * errorTypeOut = nullptr);
  24. class SRCINFO;
  25. class ActiveScriptError;
  26. class ScriptException
  27. {
  28. public:
  29. int32 ichMin;
  30. int32 ichLim;
  31. EXCEPINFO ei;
  32. public:
  33. ScriptException()
  34. { memset(this, 0, sizeof(*this)); }
  35. ~ScriptException(void);
  36. public:
  37. void CopyInto(ScriptException *pse);
  38. void Free();
  39. void GetError(HRESULT *phr, EXCEPINFO *pei); // Clears error.
  40. };
  41. class CompileScriptException : public ScriptException
  42. {
  43. public:
  44. int32 line; // line number of error (zero based)
  45. int32 ichMinLine; // starting char of the line
  46. bool hasLineNumberInfo;
  47. // TODO: if the line contains \0 character the substring following \0 will not be included:
  48. BSTR bstrLine; // source line (if available)
  49. public:
  50. CompileScriptException(void) : ScriptException(), line(0), ichMinLine(0), hasLineNumberInfo(false),
  51. bstrLine(nullptr)
  52. { }
  53. ~CompileScriptException();
  54. public:
  55. void Free();
  56. void GetError(HRESULT *phr, EXCEPINFO *pei)
  57. {
  58. ScriptException::GetError(phr, pei);
  59. Free();
  60. }
  61. void CopyInto(CompileScriptException* cse);
  62. HRESULT ProcessError(IScanner * pScan, HRESULT hr, ParseNode * pnodeBase);
  63. friend class ActiveScriptError;
  64. };