Skip to content

Commit 3bd52a3

Browse files
committed
perf: 🦺 improve error handling for auto sync
1 parent a780eb0 commit 3bd52a3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

‎src/main.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -634,12 +634,18 @@ export default class ReadwiseMirror extends Plugin {
634634
this._readwiseApi = new ReadwiseApi(this.settings.apiToken, this.notify, this._logger);
635635

636636
this.logger.info('Validating Readwise token ...');
637-
this._readwiseApi.validateToken().then((isValid) => {
638-
if (isValid && this.settings.autoSync) {
639-
this.notify.notice('Readwise: Run auto sync on startup');
640-
this.sync();
641-
}
642-
});
637+
// Run sync if we have a valid token and auto sync is enabled
638+
this._readwiseApi
639+
.validateToken()
640+
.then((isValid) => {
641+
if (isValid && this.settings.autoSync) {
642+
this.notify.notice('Readwise: Run auto sync on startup');
643+
this.sync();
644+
}
645+
})
646+
.catch((error) => {
647+
this.notify.notice(`Readwise: Error validating token, please check your API token: ${error}`);
648+
});
643649

644650
if (this.settings.lastUpdated)
645651
this.notify.setStatusBarText(`Readwise: Updated ${this.lastUpdatedHumanReadableFormat()}`);

0 commit comments

Comments
 (0)