mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
aider: If the fetch fails, skip the rest.
# Aider chat conversation: USER: if the fetch fails, skip the rest ASSISTANT: To handle fetch failures, we need to modify the `share/index.md` file. We will add a `.catch` block to the fetch promise chain to handle any errors that occur during the fetch operation. Here is the proposed change: ```markdown share/index.md <<<<<<< ORIGINAL fetch(conv) .then(response => response.text()) .then(markdown => { // Ensure every line that starts with '>' ends with exactly 2 spaces markdown = markdown.split('\n').map(function(line) { if (line.startsWith('>')) { return line.trimEnd() + ' '; } return line; }).join('\n'); var html = marked.parse(markdown); var divElement = document.querySelector('.chat-transcript'); divElement.innerHTML = html; }); ======= fetch(conv) .then(response => response.text()) .then(markdown => { // Ensure every line that starts with '>' ends with exactly 2 spaces markdown = markdown.split('\n').map(function(line) { if (line.startsWith('>')) { return line.trimEnd() + ' '; } return line; }).join('\n'); var html = marked.parse(markdown); var divElement = document.querySelector('.chat-transcript'); divElement.innerHTML = html; }) .catch(error => { console.error('Error fetching markdown:', error); }); >>>>>>> UPDATED ``` This change adds a `.catch` block to the fetch promise chain. If an error occurs during the fetch operation, the error will be logged to the console and the rest of the script will be skipped.
This commit is contained in:
parent
c5d80e9f7a
commit
7aed0438fe
1 changed files with 3 additions and 0 deletions
|
@ -28,6 +28,9 @@ window.onload = function() {
|
|||
var html = marked.parse(markdown);
|
||||
var divElement = document.querySelector('.chat-transcript');
|
||||
divElement.innerHTML = html;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error fetching markdown:', error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue