ThrowErrorObject.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  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. namespace Js
  7. {
  8. //
  9. // This object throws an error when invoked.
  10. //
  11. class ThrowErrorObject : public RecyclableObject
  12. {
  13. private:
  14. Field(JavascriptError*) m_error;
  15. protected:
  16. ThrowErrorObject(StaticType* type, JavascriptError* error);
  17. DEFINE_VTABLE_CTOR(ThrowErrorObject, RecyclableObject);
  18. public:
  19. static Var DefaultEntryPoint(RecyclableObject* function, CallInfo callInfo, ...);
  20. static ThrowErrorObject* New(StaticType* type, JavascriptError* error, Recycler* recycler);
  21. static bool Is(Var aValue);
  22. static ThrowErrorObject* FromVar(Var aValue);
  23. static ThrowErrorObject* UnsafeFromVar(Var aValue);
  24. static RecyclableObject* CreateThrowTypeErrorObject(ScriptContext* scriptContext, int32 hCode, PCWSTR varName);
  25. static RecyclableObject* CreateThrowTypeErrorObject(ScriptContext* scriptContext, int32 hCode, JavascriptString* varName);
  26. private:
  27. typedef JavascriptError* (JavascriptLibrary::*CreateErrorFunc)();
  28. static RecyclableObject* CreateThrowErrorObject(CreateErrorFunc createError, ScriptContext* scriptContext, int32 hCode, PCWSTR varName);
  29. };
  30. }