add extra error handling
This commit is contained in:
parent
5d0cd02c21
commit
7298023fb9
@ -60,6 +60,7 @@ try {
|
||||
// Upload logic
|
||||
let lastData: Record<string, any> = {};
|
||||
async function _upload() {
|
||||
try {
|
||||
console.log('-- Reading log...');
|
||||
const reader = new MDBReader(await readFile(dbPath));
|
||||
if (!reader.getTableNames().includes('tblContacts'))
|
||||
@ -75,6 +76,8 @@ async function _upload() {
|
||||
|
||||
if (changedIds.length === 0) return void console.log('-- No changes found.');
|
||||
|
||||
try {
|
||||
|
||||
console.log(`-> Uploading ${changedIds.length.toLocaleString()} row(s)...`);
|
||||
const response = await fetch(logEndpoint, {
|
||||
method: 'POST',
|
||||
@ -85,6 +88,14 @@ async function _upload() {
|
||||
});
|
||||
console.log(`<- Recieved ${response.status} (${response.statusText})`);
|
||||
if (response.status === 200) lastData = data;
|
||||
} catch (e) {
|
||||
console.log('-! Failed to send log');
|
||||
console.error(e);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('-! Failed to upload');
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
const upload = debounce(_upload, 250);
|
||||
|
Loading…
x
Reference in New Issue
Block a user