Skip to content

Commit

Permalink
Remap oracle account deserialization errors
Browse files Browse the repository at this point in the history
Also fix extra space on last error message
  • Loading branch information
danenbm committed May 8, 2024
1 parent 64bc55b commit cd39bad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion programs/mpl-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ pub enum MplCoreError {
RequiresLifecycleCheck,

/// 37 - Duplicate lifecycle checks were provided for external plugin
#[error("Duplicate lifecycle checks were provided for external plugin ")]
#[error("Duplicate lifecycle checks were provided for external plugin")]
DuplicateLifecycleChecks,

/// 38 - Could not read from oracle account
#[error("Could not read from oracle account")]
InvalidOracleAccountData,
}

impl PrintProgramError for MplCoreError {
Expand Down
3 changes: 2 additions & 1 deletion programs/mpl-core/src/plugins/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ impl Oracle {

let offset = self.results_offset.to_offset_usize();
let validation_result =
OracleValidation::deserialize(&mut &(*oracle_account.data).borrow()[offset..])?;
OracleValidation::deserialize(&mut &(*oracle_account.data).borrow()[offset..])
.map_err(|_| MplCoreError::InvalidOracleAccountData)?;

match validation_result {
OracleValidation::V1 {
Expand Down

0 comments on commit cd39bad

Please sign in to comment.