fix: avoid errors and add default empty string#202
Conversation
|
📦 Web extension build artifacts: https://github.com/dataforgoodfr/14_BalanceTesHaters/actions/runs/24100723514/artifacts/6313903867 |
|
Testé sur ces deux cas qui ne fonctionnaient pas : |
in case the comment is empty, defaults with empty string. In some cases, the comments container is not the third but the second div.
8f378f2 to
5d4f619
Compare
| HTMLElement, | ||
| return tryOrElse( | ||
| () => | ||
| this.scrapingSupport.selectOrThrow( |
There was a problem hiding this comment.
Je pense qu'utiliser this.scrapingSupport.select plutôt que faire un catch sur selectOrThrow serait plus simple ici.
Par exemple le code suivant serait équivalent
return this.scrapingSupport.select(element, ":scope span>div>span", HTMLElement)?.textContent || "";
| HTMLElement, | ||
| const commentsContainer = tryOrElse( | ||
| () => | ||
| this.scrapingSupport.selectOrThrow( |
There was a problem hiding this comment.
ici aussi select serait peut-être plus adapté.
|
|
||
| for (const comment of commentElements) { | ||
| comments.push(this.scrapCommentThread(comment)); | ||
| try { |
There was a problem hiding this comment.
Dans quel cas ce try -catch est-il utile?
Est-ce pour ajouter plus de résilience de manière générale ou pour gérer un cas en particulier?
| baseElement, | ||
| ":scope>div>div:nth-of-type(2)>span", | ||
| HTMLElement, | ||
| const postContent = tryOrElse( |
There was a problem hiding this comment.
je privilegierais là aussi select a la place de selctOrThrow + tryOrElse
in case the comment is empty, defaults with empty string. In some cases, the comments container is not the third but the second div.
…ithub.com:dataforgoodfr/14_BalanceTesHaters into fix/110-instagram-capture-fails-if-no-description
in case the comment is empty, defaults with empty string. In some cases, the comments container is not the third but the second div.
in case the comment is empty, defaults with empty string. In some cases, the comments container is not the third but the second div.
…ithub.com:dataforgoodfr/14_BalanceTesHaters into fix/110-instagram-capture-fails-if-no-description
Fixes #110
in case the comment is empty, defaults with empty string. In some cases, the comments container is not the third but the second div.