Skip to content

Commit

Permalink
Updated UrlCheckController.java
Browse files Browse the repository at this point in the history
  • Loading branch information
alina tarasova committed Mar 14, 2024
1 parent 175cb09 commit 2c40933
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/src/main/java/hexlet/code/controller/UrlCheckController.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@
import kong.unirest.HttpResponse;

import java.sql.SQLException;
import java.util.Optional;

public class UrlCheckController {
public static void createCheck(Context ctx) throws SQLException {
long urlId = ctx.pathParamAsClass("id", Long.class).getOrDefault(null);

Url url = UrlsRepository.find(urlId)
.orElseThrow(() -> new NotFoundResponse("Url with id = " + urlId + " not found"));
Optional<Url> optional = UrlsRepository.find(urlId);

if (optional.isEmpty()) {
throw new SQLException("No such mane in DB");
}
Url url = optional.get();
// Url url = UrlsRepository.find(urlId)
// .orElseThrow(() -> new NotFoundResponse("Url with id = " + urlId + " not found"));

try {
//дергаю страницу по url:
Expand Down

0 comments on commit 2c40933

Please sign in to comment.