{"record":{"id":"b75fbe573f47f9de","repo":"MuntashirAkon/AppManager","slug":"unknown-error-occurred-restoreop","errorCode":null,"errorMessage":"Unknown error occurred","messagePattern":"Unknown error occurred","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java","lineNumber":203,"sourceCode":"            if (mRequestedFlags.backupData()) {\n                restoreData();\n                if (mBackupMetadata.keyStore) {\n                    restoreKeyStore();\n                }\n                incrementProgress(progressHandler);\n            }\n            if (mRequestedFlags.backupExtras()) {\n                restoreExtras();\n                incrementProgress(progressHandler);\n            }\n            if (mRequestedFlags.backupRules()) {\n                restoreRules();\n                incrementProgress(progressHandler);\n            }\n        } catch (BackupException e) {\n            throw e;\n        } catch (Throwable th) {\n            throw new BackupException(\"Unknown error occurred\", th);\n        }\n    }\n\n    private static void incrementProgress(@Nullable ProgressHandler progressHandler) {\n        if (progressHandler == null) {\n            return;\n        }\n        float current = progressHandler.getLastProgress() + 1;\n        progressHandler.postUpdate(current);\n    }\n\n    public boolean requiresRestart() {\n        return mRequiresRestart;\n    }\n\n    private void verifyMetadata() throws BackupException {\n        boolean isV5AndUp = mBackupItem.isV5AndUp();\n        if (isV5AndUp) {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java#L185-L221","documentation":"runRestore rethrows BackupException as-is but wraps every other Throwable into a generic BackupException 'Unknown error occurred'. This catch-all marks an unexpected failure anywhere in the restore pipeline (I/O, decompression, rules application, progress handling) that no specific branch anticipated.","triggerScenarios":"Any non-BackupException Throwable during runRestore: tar extraction failure, IOException on package files, NullPointerException, OOM, interruption during restoreRules or per-item steps.","commonSituations":"Corrupted archive members inside the backup; storage full mid-restore; app bug surfacing as NPE; device ran out of memory restoring a large app; restore interrupted by system killing the process.","solutions":["Read the wrapped cause (getCause()) — it names the real failing operation","Check free storage space and retry the restore","Verify the backup archive files are not truncated/corrupt","Reproduce with logging enabled and report the cause stack trace if it indicates an app bug"],"exampleFix":"// before\n} catch (Throwable th) {\n    throw new BackupException(\"Unknown error occurred\", th);\n}\n// after\n} catch (IOException e) {\n    throw new BackupException(\"Restore failed on backup files: \" + e.getMessage(), e);\n} catch (Throwable th) {\n    throw new BackupException(\"Unknown error occurred: \" + th.getClass().getName(), th);\n}","handlingStrategy":"try-catch","validationCode":"long usable = new File(restoreTarget).getUsableSpace();\nif (usable < estimatedBackupSize) throw new BackupException(\"Insufficient storage for restore\");","typeGuard":null,"tryCatchPattern":"try { runRestore(progressHandler); } catch (BackupException e) { Throwable cause = e.getCause(); log(\"Restore failed: \" + (cause != null ? cause : e)); retryOnceOrReport(cause); }","preventionTips":["Always inspect getCause() — the generic message hides the real failure","Ensure sufficient free storage and battery before large restores","Keep the app updated; report unexpected causes as bugs with full stack traces","Avoid killing the process mid-restore"],"tags":["restore","backup","android","unexpected"],"backgroundTag":"internal-invariant-violation","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}