Skip to content

Commit

Permalink
fix: throw a custom exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Macaku committed Jan 16, 2024
1 parent b245fc4 commit fe1fbe4
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.achobeta.domain.shortlink.service.ShortLinkService;
import com.achobeta.domain.shortlink.util.HttpUrlValidator;
import com.achobeta.domain.shortlink.util.ShortLinkUtils;
import com.achobeta.exception.IllegalUrlException;
import com.achobeta.exception.ShortLinkGenerateException;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -42,7 +43,7 @@ public RedirectView getShortLink(@PathVariable("code")String code) {
public SystemJsonResponse transferAndSaveShortLink(HttpServletRequest request, @RequestParam("url")String url) {
//验证url
if(!HttpUrlValidator.isHttpUrl(url) || !HttpUrlValidator.isUrlAccessible(url)) {
throw new ShortLinkGenerateException("url无效");
throw new IllegalUrlException("url无效");
}
// 拼接出基础的url
String baseUrl = ShortLinkUtils.getBaseUrl(request.getHeader("host"));
Expand Down

0 comments on commit fe1fbe4

Please sign in to comment.