Skip to content
Snippets Groups Projects
Unverified Commit 2bc61463 authored by Jed Fox's avatar Jed Fox Committed by GitHub
Browse files

Log more debugging information for an invalid-schema sync error (#671)

* Provide more debugging information when throwing an invalid-schema sync error

* Don’t log the errors directly

* Update dynamic cell warning to be clearer

* rebuild
parent cb0ae2d3
No related branches found
No related tags found
No related merge requests found
......@@ -227,6 +227,7 @@ export function listenForSyncEvent(actions, store) {
}
break;
case 'invalid-schema':
console.trace('invalid-schema', meta);
notif = {
title: 'Update required',
message:
......@@ -236,6 +237,7 @@ export function listenForSyncEvent(actions, store) {
};
break;
case 'apply-failure':
console.trace('apply-failure', meta);
notif = {
message: `We couldn't apply that change to the database. Please report this as a bug by [opening a Github issue](${githubIssueLink}).`,
};
......@@ -245,6 +247,7 @@ export function listenForSyncEvent(actions, store) {
// Show nothing
break;
default:
console.trace('unkown error', info);
notif = {
message: `We had problems syncing your changes. Please report this as a bug by [opening a Github issue](${githubIssueLink}).`,
};
......
......@@ -133,7 +133,7 @@ export default class Spreadsheet {
if (result instanceof Promise) {
console.warn(
'dynamic cell returned a promise! this is discouraged because errors are not handled properly',
`dynamic cell ${name} returned a promise! this is discouraged because errors are not handled properly`,
);
}
} else if (node.sql) {
......
......@@ -75,8 +75,8 @@ function apply(msg, prev) {
if (dataset === 'prefs') {
// Do nothing, it doesn't exist in the db
} else {
let query;
try {
let query;
if (prev) {
query = {
sql: db.cache(`UPDATE ${dataset} SET ${column} = ? WHERE id = ?`),
......@@ -90,9 +90,11 @@ function apply(msg, prev) {
}
db.runQuery(query.sql, query.params);
} catch (e) {
//console.log(e);
throw new SyncError('invalid-schema');
} catch (error) {
throw new SyncError('invalid-schema', {
error: { message: error.message, stack: error.stack },
query,
});
}
}
}
......@@ -128,8 +130,8 @@ async function fetchAll(table, ids) {
try {
let rows = await db.runQuery(sql, partIds, true);
results = results.concat(rows);
} catch (e) {
throw new SyncError('invalid-schema');
} catch (error) {
throw new SyncError('invalid-schema', { error, sql, params: partIds });
}
}
......@@ -415,9 +417,10 @@ async function _sendMessages(messages) {
app.events.emit('sync', {
type: 'error',
subtype: 'apply-failure',
meta: e.meta,
});
} else {
app.events.emit('sync', { type: 'error' });
app.events.emit('sync', { type: 'error', meta: e.meta });
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment