DOMException.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/DOM/DOMException.h>
  7. #include <LibWeb/HTML/Window.h>
  8. namespace Web::DOM {
  9. JS::NonnullGCPtr<DOMException> DOMException::create(JS::Object& global_object, FlyString const& name, FlyString const& message)
  10. {
  11. auto& window = verify_cast<HTML::Window>(global_object);
  12. return *window.heap().allocate<DOMException>(window.realm(), window, name, message);
  13. }
  14. JS::NonnullGCPtr<DOMException> DOMException::create_with_global_object(JS::Object& global_object, FlyString const& message, FlyString const& name)
  15. {
  16. auto& window = verify_cast<HTML::Window>(global_object);
  17. return *window.heap().allocate<DOMException>(window.realm(), window, name, message);
  18. }
  19. DOMException::DOMException(HTML::Window& window, FlyString const& name, FlyString const& message)
  20. : PlatformObject(window.realm())
  21. , m_name(name)
  22. , m_message(message)
  23. {
  24. set_prototype(&window.cached_web_prototype("DOMException"));
  25. }
  26. DOMException::~DOMException() = default;
  27. }