DOMException.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/WebIDL/DOMException.h>
  8. namespace Web::WebIDL {
  9. JS::NonnullGCPtr<DOMException> DOMException::create(JS::Realm& realm, DeprecatedFlyString const& name, DeprecatedFlyString const& message)
  10. {
  11. return realm.heap().allocate<DOMException>(realm, realm, name, message).release_allocated_value_but_fixme_should_propagate_errors();
  12. }
  13. JS::NonnullGCPtr<DOMException> DOMException::construct_impl(JS::Realm& realm, DeprecatedFlyString const& message, DeprecatedFlyString const& name)
  14. {
  15. return realm.heap().allocate<DOMException>(realm, realm, name, message).release_allocated_value_but_fixme_should_propagate_errors();
  16. }
  17. DOMException::DOMException(JS::Realm& realm, DeprecatedFlyString const& name, DeprecatedFlyString const& message)
  18. : PlatformObject(realm)
  19. , m_name(name)
  20. , m_message(message)
  21. {
  22. }
  23. DOMException::~DOMException() = default;
  24. JS::ThrowCompletionOr<void> DOMException::initialize(JS::Realm& realm)
  25. {
  26. MUST_OR_THROW_OOM(Base::initialize(realm));
  27. set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMExceptionPrototype>(realm, "DOMException"));
  28. return {};
  29. }
  30. }