refactor RTCError::new_inherited (#35617)

Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
This commit is contained in:
Yerkebulan Tulibergenov 2025-02-23 06:26:19 -08:00 committed by GitHub
parent 381e168877
commit 6199099d12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,16 +9,16 @@ use crate::dom::bindings::codegen::Bindings::RTCErrorBinding::{
RTCErrorDetailType, RTCErrorInit, RTCErrorMethods, RTCErrorDetailType, RTCErrorInit, RTCErrorMethods,
}; };
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomGlobal}; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomGlobal};
use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString; use crate::dom::bindings::str::DOMString;
use crate::dom::domexception::{DOMErrorName, DOMException}; use crate::dom::domexception::DOMException;
use crate::dom::globalscope::GlobalScope; use crate::dom::globalscope::GlobalScope;
use crate::dom::window::Window; use crate::dom::window::Window;
use crate::script_runtime::CanGc; use crate::script_runtime::CanGc;
#[dom_struct] #[dom_struct]
pub(crate) struct RTCError { pub(crate) struct RTCError {
exception: Dom<DOMException>, exception: DOMException,
error_detail: RTCErrorDetailType, error_detail: RTCErrorDetailType,
sdp_line_number: Option<i32>, sdp_line_number: Option<i32>,
http_request_status_code: Option<i32>, http_request_status_code: Option<i32>,
@ -28,18 +28,9 @@ pub(crate) struct RTCError {
} }
impl RTCError { impl RTCError {
fn new_inherited( fn new_inherited(init: &RTCErrorInit, message: DOMString) -> RTCError {
global: &GlobalScope,
init: &RTCErrorInit,
message: DOMString,
can_gc: CanGc,
) -> RTCError {
RTCError { RTCError {
exception: Dom::from_ref(&*DOMException::new( exception: DOMException::new_inherited(message, "OperationError".into()),
global,
DOMErrorName::from(&message).unwrap(),
can_gc,
)),
error_detail: init.errorDetail, error_detail: init.errorDetail,
sdp_line_number: init.sdpLineNumber, sdp_line_number: init.sdpLineNumber,
http_request_status_code: init.httpRequestStatusCode, http_request_status_code: init.httpRequestStatusCode,
@ -66,7 +57,7 @@ impl RTCError {
can_gc: CanGc, can_gc: CanGc,
) -> DomRoot<RTCError> { ) -> DomRoot<RTCError> {
reflect_dom_object_with_proto( reflect_dom_object_with_proto(
Box::new(RTCError::new_inherited(global, init, message, can_gc)), Box::new(RTCError::new_inherited(init, message)),
global, global,
proto, proto,
can_gc, can_gc,