Skip to content

Commit

Permalink
fix(skymp5-server): replace exceptions with logs in ObjectReference.R…
Browse files Browse the repository at this point in the history
…emoveItem (#2044)
  • Loading branch information
Pospelove authored Jun 28, 2024
1 parent 7ea4225 commit 92b3944
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,20 @@ VarValue PapyrusObjectReference::RemoveItem(

auto worldState = selfRefr->GetParent();
if (!worldState) {
throw std::runtime_error("RemoveItem - no WorldState attached");
spdlog::error("RemoveItem {:x} - no WorldState attached",
selfRefr->GetFormId());
return VarValue::None();
}

if (!selfRefr || !item.rec)
return VarValue::None();

if (!espm::utils::Is<espm::FLST>(item.rec->GetType())) {
if (!espm::utils::IsItem(item.rec->GetType())) {
throw std::runtime_error("RemoveItem - form is not an item");
spdlog::error("RemoveItem {:x} - form {:x} is not an item, it is {}",
selfRefr->GetFormId(), item.ToGlobalId(item.rec->GetId()),
item.rec->GetType().ToString());
return VarValue::None();
}
}

Expand All @@ -205,8 +210,10 @@ VarValue PapyrusObjectReference::RemoveItem(
espm::Convert<espm::LIGH>(item.rec)->GetData(worldState->GetEspmCache());
bool isTorch = res.data.flags & espm::LIGH::Flags::CanBeCarried;
if (!isTorch) {
throw std::runtime_error(
"RemoveItem - form is LIGH without CanBeCarried flag");
spdlog::error(
"RemoveItem {:x} - form {:x} is LIGH without CanBeCarried flag",
selfRefr->GetFormId(), item.ToGlobalId(item.rec->GetId()));
return VarValue::None();
}
}

Expand Down

0 comments on commit 92b3944

Please sign in to comment.