avm1: Don't log errors at every Activation, only at the "root" frames

This commit is contained in:
Nathan Adams 2020-07-07 00:13:19 +02:00 committed by Mike Welsh
parent 8218e14824
commit 3ee1902117
2 changed files with 6 additions and 14 deletions

View File

@ -384,13 +384,16 @@ pub fn root_error_handler<'gc>(
context: &mut UpdateContext<'_, 'gc, '_>,
error: Error<'gc>,
) {
if let Error::ThrownValue(error) = error {
if let Error::ThrownValue(error) = &error {
let string = error
.coerce_to_string(activation, context)
.unwrap_or_else(|_| Cow::Borrowed("undefined"));
log::info!(target: "avm_trace", "{}", string);
} else {
log::error!("Uncaught error: {:?}", error);
log::error!("{}", error);
}
if error.is_halting() {
activation.avm.halt();
}
}

View File

@ -386,7 +386,7 @@ impl<'a, 'gc: 'a> Activation<'a, 'gc> {
} else if let Some(action) = reader.read_action()? {
avm_debug!("({}) Action: {:?}", self.id.depth(), action);
let result = match action {
match action {
Action::Add => self.action_add(context),
Action::Add2 => self.action_add_2(context),
Action::And => self.action_and(context),
@ -516,18 +516,7 @@ impl<'a, 'gc: 'a> Activation<'a, 'gc> {
Action::Throw => self.action_throw(context),
Action::Try(try_block) => self.action_try(context, &try_block, &data),
_ => self.unknown_op(context, action),
};
if let Err(e) = result {
match &e {
Error::ThrownValue(_) => {}
e => log::error!("AVM1 error: {}", e),
}
if e.is_halting() {
self.avm.halt();
}
return Err(e);
}
result
} else {
//The explicit end opcode was encountered so return here
Ok(FrameControl::Return(ReturnType::Implicit))