Skip to content

Commit

Permalink
[Move] Return error instead of panicking on primitive type event (Mys…
Browse files Browse the repository at this point in the history
  • Loading branch information
awelc authored Jun 17, 2022
1 parent 9c4b188 commit d13a50f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/sui-framework/src/natives/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use crate::EventType;
use move_binary_format::errors::PartialVMResult;
use move_core_types::gas_schedule::GasAlgebra;
use move_binary_format::errors::{PartialVMError, PartialVMResult};
use move_core_types::{gas_schedule::GasAlgebra, vm_status::StatusCode};
use move_vm_runtime::native_functions::NativeContext;
use move_vm_types::{
gas_schedule::NativeCostIndex,
Expand Down Expand Up @@ -33,8 +33,9 @@ pub fn emit(
match ty {
Type::Struct(..) | Type::StructInstantiation(..) => (),
ty => {
// TODO: // TODO(https://github.com/MystenLabs/sui/issues/19): enforce this in the ability system
panic!("Unsupported event type {:?}--struct expected", ty)
// TODO (https://github.com/MystenLabs/sui/issues/19): ideally enforce this in the ability system
return Err(PartialVMError::new(StatusCode::DATA_FORMAT_ERROR)
.with_message(format!("Unsupported event type {:?} (struct expected)", ty)));
}
}

Expand Down

0 comments on commit d13a50f

Please sign in to comment.