Replace most panics in the core library with results
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2023-04-19 18:44:11 +02:00
parent 00d596d656
commit c0e4702e45
33 changed files with 222 additions and 102 deletions

View File

@@ -160,6 +160,7 @@ impl ValueIdentifiable for ChoiceQueue {
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
mod tests {
use super::*;
use crate::defines::LevelInt;

View File

@@ -213,7 +213,7 @@ impl Battle {
.library()
.static_data()
.types()
.get_effectiveness(hit_type, &target.types());
.get_effectiveness(hit_type, &target.types())?;
script_hook!(
change_effectiveness,
executing_move,

View File

@@ -147,6 +147,7 @@ impl ValueIdentifiable for Gen7BattleStatCalculator {
}
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
pub mod tests {
use super::*;

View File

@@ -127,6 +127,7 @@ impl ValueIdentifiable for DynamicLibraryImpl {
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
pub mod test {
use super::*;
use crate::dynamic_data::libraries::battle_stat_calculator::Gen7BattleStatCalculator;

View File

@@ -101,6 +101,7 @@ impl ValueIdentifiable for LearnedMove {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use super::*;
use crate::static_data::tests::MockMoveData;

View File

@@ -421,7 +421,7 @@ impl Pokemon {
}
let form = self.form();
let ability = form.get_ability(self.ability_index);
let ability = form.get_ability(self.ability_index)?;
Ok(self
.library
.static_data()

View File

@@ -53,7 +53,7 @@ impl PokemonBuilder {
.species()
.get(&self.species)
.ok_or(PkmnError::InvalidSpeciesName { species: self.species })?;
let form = species.get_default_form();
let form = species.get_default_form()?;
let p = Pokemon::new(
self.library,
species,

View File

@@ -388,6 +388,8 @@ impl Clone for ScriptContainer {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
mod tests {
use std::sync::atomic::{AtomicBool, AtomicPtr};