Skip to content

Commit

Permalink
feat(sync): improve error handling #599
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesjo committed Oct 21, 2020
1 parent 59897f0 commit 6aa0dae
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/app/imex/sync/dropbox/dropbox-sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { SyncProvider, SyncProviderServiceInterface } from '../sync-provider.mod
@Injectable({providedIn: 'root'})
export class DropboxSyncService implements SyncProviderServiceInterface {
id: SyncProvider = SyncProvider.Dropbox;
isUploadForcePossible: boolean = true;

isReady$: Observable<boolean> = this._dataInitService.isAllDataLoadedInitially$.pipe(
concatMap(() => this._dropboxApiService.isTokenAvailable$),
Expand Down
1 change: 1 addition & 0 deletions src/app/imex/sync/sync-provider.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type SyncFileMeta = DropboxFileMetadata | GoogleDriveFileMeta;

export interface SyncProviderServiceInterface {
id: SyncProvider;
isUploadForcePossible?: boolean;
isReady$: Observable<boolean>;
isReadyForRequests$: Observable<boolean>;

Expand Down
14 changes: 11 additions & 3 deletions src/app/imex/sync/sync-provider.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class SyncProviderService {
this._snackService.open({
msg: T.F.SYNC.S.UNKNOWN_ERROR,
translateParams: {
err: truncate(revRes.toString()),
err: truncate(revRes.toString(), 100),
},
type: 'ERROR'
});
Expand Down Expand Up @@ -244,8 +244,16 @@ export class SyncProviderService {
this._log(cp, '↑ Uploaded Data ↑ ✓');
} else {
this._log(cp, 'X Upload Request Error');
if (this._c(T.F.SYNC.C.FORCE_UPLOAD_AFTER_ERROR)) {
return this._uploadAppData(cp, data, true);
if (cp.isUploadForcePossible && this._c(T.F.SYNC.C.FORCE_UPLOAD_AFTER_ERROR)) {
return await this._uploadAppData(cp, data, true);
} else {
this._snackService.open({
msg: T.F.SYNC.S.UPLOAD_ERROR,
translateParams: {
err: truncate(successRev.toString(), 100),
},
type: 'ERROR'
});
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/t.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,8 @@ const T = {
ERROR_INVALID_DATA: 'F.SYNC.S.ERROR_INVALID_DATA',
IMPORTING: 'F.SYNC.S.IMPORTING',
SUCCESS: 'F.SYNC.S.SUCCESS',
UNKNOWN_ERROR: 'F.SYNC.S.UNKNOWN_ERROR'
UNKNOWN_ERROR: 'F.SYNC.S.UNKNOWN_ERROR',
UPLOAD_ERROR: 'F.SYNC.S.UPLOAD_ERROR'
}
},
TAG: {
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,8 @@
"ERROR_INVALID_DATA": "Error while syncing. Invalid data",
"IMPORTING": "Importing data",
"SUCCESS": "Data imported",
"UNKNOWN_ERROR": "Unknown error while syncing. Please check console."
"UNKNOWN_ERROR": "Unknown Sync Error: {{err}}",
"UPLOAD_ERROR": "Unknown Upload Error (Settings correct?): {{err}}"
}
},
"TAG": {
Expand Down

0 comments on commit 6aa0dae

Please sign in to comment.