Skip to content

Commit

Permalink
Merge pull request #302 from openzim/better-error-message
Browse files Browse the repository at this point in the history
Improve an error message
  • Loading branch information
kelson42 committed May 9, 2022
2 parents 5b467b9 + 86923ba commit 9443091
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/zimwriterfs/zimcreatorfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ std::string ZimCreatorFS::parseAndAdaptHtml(std::string& data, std::string& titl
}
}

/* Detect if this is a redirection (if no redirects TSV file specified)
/* Detect if this is a HTML redirection (if no redirects TSV
file specified)
*/
std::string targetUrl;
try {
Expand All @@ -288,8 +289,10 @@ std::string ZimCreatorFS::parseAndAdaptHtml(std::string& data, std::string& titl
}
if (!targetUrl.empty()) {
auto redirectUrl = computeAbsolutePath(url, decodeUrl(targetUrl));
if (!fileExists(directoryPath + "/" + redirectUrl)) {
throw std::runtime_error("Target path doesn't exists");
auto redirectUrlPath = directoryPath + "/" + redirectUrl;
if (!fileExists(redirectUrlPath)) {
throw std::runtime_error("'" + url + "' HTML redirection target path '"
+ redirectUrlPath + "' doesn't exist.");
}
return redirectUrl;
}
Expand Down

0 comments on commit 9443091

Please sign in to comment.