-
Notifications
You must be signed in to change notification settings - Fork 6
Description
While implementing the config migration from v1 to v2 in the desktop app, I noticed that sync() would not surface the invalid token error returned from the server.
Consider the following case:
- The app's token has become invalid
- The app attempts to perform a soft sync e.g.:
syncManager.sync(force) // force == false- The reported failure will be:
org.json.JSONException: JSONObject["count"] not found.
at org.json.JSONObject.get(JSONObject.java:596)
at org.json.JSONObject.getInt(JSONObject.java:768)
at eu.pretix.libpretixsync.sync.BaseDownloadSyncAdapter.downloadData(BaseDownloadSyncAdapter.kt:205)
at eu.pretix.libpretixsync.sync.BaseDownloadSyncAdapter.download(BaseDownloadSyncAdapter.kt:56)
at eu.pretix.libpretixsync.sync.AllSubEventsSyncAdapter.download(AllSubEventsSyncAdapter.kt:125)
at eu.pretix.libpretixsync.sync.SyncManager.download(SyncManager.java:333)
at eu.pretix.libpretixsync.sync.SyncManager.downloadData(SyncManager.java:392)
at eu.pretix.libpretixsync.sync.SyncManager.sync(SyncManager.java:181)
The first method to encounter the server error in this callstack is fetchDeviceInfo() which receives the following vdata response:
{"detail":"Invalid token."}but throws a org.json.JSONException: JSONObject["server"] not found. error because of the following:
configStore.setKnownPretixVersion(vdata.getJSONObject("server").getJSONObject("version").getLong("pretix_numeric"));:
This is just printed and it won't be until a later JSON error during the downloadData() method that an uncaught JSON error surfaces back the caller.
This is not blocking, and I imagine it happens only if the device access is somehow revoked from the pretix but it will be nice to have way to show the actual reason instead of the JSON error.