Skip to content

Commit 90b5613

Browse files
authored
Merge pull request #28 from TeamCodeStream/feature/more-errors
Add some more errors
2 parents 1f349d1 + dbf810b commit 90b5613

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,12 @@ private Page<Owner> findPaginatedForOwnersLastName(int page, String lastname) {
140140
ControllerValidation.ValidatePageNumber(page);
141141

142142
int pageSize = 5;
143-
Pageable pageable = PageRequest.of(page - 1, pageSize);
144-
return owners.findByLastName(lastname, pageable);
143+
int startPage = page - 1;
144+
145+
ControllerValidation.ValidatePageNumber(startPage);
146+
Pageable pageable = PageRequest.of(startPage, pageSize);
145147

148+
return owners.findByLastName(lastname, pageable);
146149
}
147150

148151
@GetMapping("/owners/{ownerId}/edit")

src/main/java/org/springframework/samples/petclinic/owner/PetController.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ public Pet findPet(@PathVariable("ownerId") int ownerId,
7575
}
7676

7777
Owner owner = this.owners.findById(ownerId);
78-
if (owner == null) {
79-
throw new IllegalArgumentException("Owner ID not found: " + ownerId);
80-
}
78+
ControllerValidation.ValidateNotNull(owner, "Owner");
8179
return owner.getPet(petId);
8280
}
8381

0 commit comments

Comments
 (0)