diff --git a/core/src/avm2/error.rs b/core/src/avm2/error.rs index d8156374c..2c495b425 100644 --- a/core/src/avm2/error.rs +++ b/core/src/avm2/error.rs @@ -204,6 +204,24 @@ pub fn make_error_1010<'gc>( } } +#[inline(never)] +#[cold] +pub fn make_error_1014<'gc>( + activation: &mut Activation<'_, 'gc>, + class_name: AvmString<'gc>, +) -> Error<'gc> { + let err = verify_error( + activation, + &format!("Error #1014: Class {} could not be found.", class_name), + 1014, + ); + + match err { + Ok(err) => Error::AvmError(err), + Err(err) => err, + } +} + #[inline(never)] #[cold] pub fn make_error_1021<'gc>(activation: &mut Activation<'_, 'gc>) -> Error<'gc> { diff --git a/core/src/avm2/verify.rs b/core/src/avm2/verify.rs index 357a1472c..8326875ec 100644 --- a/core/src/avm2/verify.rs +++ b/core/src/avm2/verify.rs @@ -1,7 +1,7 @@ use crate::avm2::class::Class; use crate::avm2::error::{ - make_error_1021, make_error_1025, make_error_1032, make_error_1054, make_error_1107, - verify_error, + make_error_1014, make_error_1021, make_error_1025, make_error_1032, make_error_1054, + make_error_1107, verify_error, }; use crate::avm2::method::BytecodeMethod; use crate::avm2::multiname::Multiname; @@ -299,27 +299,16 @@ pub fn verify_method<'gc>( if multiname.has_lazy_component() { // This matches FP's error message - return Err(Error::AvmError(verify_error( - activation, - "Error #1014: Class [] could not be found.", - 1014, - )?)); + return Err(make_error_1014(activation, "[]".into())); } activation .domain() .get_class(&multiname, activation.context.gc_context) .ok_or_else(|| { - Error::AvmError( - verify_error( - activation, - &format!( - "Error #1014: Class {} could not be found.", - multiname.to_qualified_name(activation.context.gc_context) - ), - 1014, - ) - .expect("Error should construct"), + make_error_1014( + activation, + multiname.to_qualified_name(activation.context.gc_context), ) })?; } @@ -419,27 +408,16 @@ pub fn verify_method<'gc>( if pooled_type_name.has_lazy_component() { // This matches FP's error message - return Err(Error::AvmError(verify_error( - activation, - "Error #1014: Class [] could not be found.", - 1014, - )?)); + return Err(make_error_1014(activation, "[]".into())); } let resolved_type = activation .domain() .get_class(&pooled_type_name, activation.context.gc_context) .ok_or_else(|| { - Error::AvmError( - verify_error( - activation, - &format!( - "Error #1014: Class {} could not be found.", - pooled_type_name.to_qualified_name(activation.context.gc_context) - ), - 1014, - ) - .expect("Error should construct"), + make_error_1014( + activation, + pooled_type_name.to_qualified_name(activation.context.gc_context), ) })?;