Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve exception message thrown when not accepting an URL in LinkHandlerFactory#fromUrl(String url, String baseUrl) #638

Merged
merged 1 commit into from
Jun 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ public LinkHandler fromUrl(final String url) throws ParsingException {
}

/**
* Builds a {@link LinkHandler} from a url and a base url. The url is expected to be already
* polished from google search redirects (otherwise how could {@code baseUrl} have been
* Builds a {@link LinkHandler} from an URL and a base URL. The URL is expected to be already
* polished from Google search redirects (otherwise how could {@code baseUrl} have been
* extracted?).<br>
* So do not call {@link Utils#followGoogleRedirectIfNeeded(String)} on the url if overriding
* So do not call {@link Utils#followGoogleRedirectIfNeeded(String)} on the URL if overriding
* this function, since that should be done in {@link #fromUrl(String)}.
* @param url the url without google search redirects to extract id from
* @param baseUrl the base url
* @param url the URL without Google search redirects to extract id from
* @param baseUrl the base URL
* @return a {@link LinkHandler} complete with information
*/
public LinkHandler fromUrl(String url, String baseUrl) throws ParsingException {
if (url == null) throw new IllegalArgumentException("url can not be null");
if (url == null) throw new IllegalArgumentException("URL cannot be null");
if (!acceptUrl(url)) {
throw new ParsingException("Malformed unacceptable url: " + url);
throw new ParsingException("URL not accepted: " + url);
}

final String id = getId(url);
Expand Down