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