Skip to content

Commit eb27a26

Browse files
committed
test(cucumber_fetch_and_save): fix the constroller so it doesn't return a 500 when the fetching size is too big
1 parent 83f3f4c commit eb27a26

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • src/main/java/com/xpeho/spring_boot_java_random_user/presentation/handlers

src/main/java/com/xpeho/spring_boot_java_random_user/presentation/handlers/UserHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
import org.slf4j.LoggerFactory;
1616
import org.springframework.http.HttpStatus;
1717
import org.springframework.http.ResponseEntity;
18+
import org.springframework.validation.annotation.Validated;
1819
import org.springframework.web.bind.annotation.RequestBody;
1920
import org.springframework.web.bind.annotation.RestController;
2021

2122
import java.io.IOException;
2223
import java.util.List;
2324

2425

26+
@Validated
2527
@RestController
2628
public class UserHandler implements UserController {
2729

@@ -70,7 +72,7 @@ public ResponseEntity<UserResponseDTO> getRandomUsers(int page, int size, UserSo
7072
);
7173
return ResponseEntity.ok(response);
7274
} catch (IOException e) {
73-
logger.error("Error fetching random users: {}", e.getMessage(), e);
75+
logger.error("Error fetching random users: {}", e.getMessage());
7476
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
7577
}
7678
}
@@ -124,6 +126,6 @@ public void deleteUserById(int id) {
124126
}
125127

126128
private void logUserNotFound(UserNotFoundException e) {
127-
logger.warn(USER_NOT_FOUND_LOG, e.getMessage(), e);
129+
logger.warn(USER_NOT_FOUND_LOG, e.getMessage());
128130
}
129131
}

0 commit comments

Comments
 (0)