Updating using GitHub API 2025-06-19-15:31

This commit is contained in:
nidhi-vm 2025-06-19 15:31:17 -04:00
parent 8d02dd678e
commit eee0247315

View file

@ -59,10 +59,8 @@ class PetController {
@ModelAttribute("owner")
public Owner findOwner(@PathVariable("ownerId") int ownerId) {
Optional<Owner> optionalOwner = this.owners.findById(ownerId);
Owner owner = optionalOwner.orElseThrow(() -> new IllegalArgumentException(
return this.owners.findById(ownerId).orElseThrow(() -> new IllegalArgumentException(
"Owner not found with id: " + ownerId + ". Please ensure the ID is correct "));
return owner;
}
@ModelAttribute("pet")
@ -73,8 +71,7 @@ class PetController {
return new Pet();
}
Optional<Owner> optionalOwner = this.owners.findById(ownerId);
Owner owner = optionalOwner.orElseThrow(() -> new IllegalArgumentException(
Owner owner = this.owners.findById(ownerId).orElseThrow(() -> new IllegalArgumentException(
"Owner not found with id: " + ownerId + ". Please ensure the ID is correct "));
return owner.getPet(petId);
}
@ -170,4 +167,4 @@ class PetController {
this.owners.save(owner);
}
}
}