Skip to content

Commit

Permalink
Improved error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
victornpb authored Sep 3, 2019
1 parent a9eb108 commit 771737f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions deleteDiscordMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
});
};
stopBtn.onclick = () => stop = stopBtn.disabled = !(startBtn.disabled = false);
popup.document.querySelector('button#clear').onclick = (e) => { logArea.innerHTML = ""; };
popup.document.querySelector('button#clear').onclick = (e) => { logArea.innerHTML = ''; };
popup.document.querySelector('button#getAuthor').onclick = (e) => {
popup.document.querySelector('input#authorId').value = JSON.parse(popup.localStorage.user_id_cache);
};
Expand All @@ -57,7 +57,7 @@
};
popup.document.querySelector('#redact').onchange = (e) => {
popup.document.body.classList.toggle('redact') &&
popup.alert(`This will attempt to redact personal information, it's NOT 100%.\nDouble check before posting screenshots online.\n\nClick again to unhide.`);
popup.alert('This will attempt to hide personal information, but make sure to double check before sharing screenshots.');
};

const logger = (type='', args) => {
Expand Down Expand Up @@ -132,7 +132,7 @@
resp = await fetch(baseURL + 'search?' + queryString, { headers });
estimatedPing = (Date.now() - s);
} catch (err) {
return log.error('Something went wrong!', err);
return log.error('Search request throwed an error:', err);
}

// not indexed yet
Expand All @@ -157,7 +157,7 @@
await wait(w);
return await recurse();
} else {
return log.error('API responded with an error!', await resp.json());
return log.error(`Error searching messages, API responded with status ${resp.status}!\n`, await resp.json());
}
}

Expand Down Expand Up @@ -195,7 +195,8 @@
estimatedPing = (estimatedPing + lastPing) / 2;
delCount++;
} catch (err) {
log.error('Failed to delete message:', message, 'Error:', err);
log.error('Delete request throwed an error:', err);
log.verb('Related object:', redact(JSON.stringify(message)));
failCount++;
}

Expand All @@ -211,7 +212,8 @@
await wait(x);
i--; // retry
} else {
log.error('API respondend with not OK status!', resp);
log.error(`Error deleting message, API responded with status ${resp.status}!`, await resp.json());
log.verb('Related object:', redact(JSON.stringify(message)));
failCount++;
}
}
Expand Down

0 comments on commit 771737f

Please sign in to comment.