forked from OpenNeo/impress
Oops, stop crashing when modeling "pets" that start with @
Ahh, we recently added a step to pet loading that sends a metadata request to `PetService.getPet`, which is now (in a sense, correctly!) raising a `PetNotFound` error when we try modeling with a "pet" that starts with `@` (a trick we use in situations where we can get an image hash for a modeling situation, but not an irl pet itself). In this change, we make it no longer a crashing issue if the pet metadata request fails: it's not a big deal to have a `PetType` have no image hash or not have it be up-to-date! In the next change, I'll also add an optimization to skip fetching it altogether in this case—but I wanted to see this work first, because the more general resilience is more important imo!
This commit is contained in:
parent
d6888f1941
commit
9d8f035360
1 changed files with 5 additions and 1 deletions
|
@ -35,7 +35,11 @@ class Pet < ApplicationRecord
|
|||
color_id: pet_data[:color_id].to_i
|
||||
)
|
||||
|
||||
new_image_hash = Pet.fetch_image_hash(self.name)
|
||||
begin
|
||||
new_image_hash = Pet.fetch_image_hash(self.name)
|
||||
rescue => error
|
||||
Rails.logger.warn "Failed to load image hash: #{error.full_message}"
|
||||
end
|
||||
self.pet_type.image_hash = new_image_hash if new_image_hash.present?
|
||||
|
||||
# With an alt style, `body_id` in the biology data refers to the body ID of
|
||||
|
|
Loading…
Reference in a new issue