{"record":{"id":"a19df8f3fc4f0c49","repo":"MuntashirAkon/AppManager","slug":"unknown-error-occurred-sbconverter","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/convert/SBConverter.java","lineNumber":153,"sourceCode":"            }\n            mChecksum.close();\n            // Encrypt checksum\n            try {\n                mBackupItem.encrypt(new Path[]{mChecksum.getFile()});\n            } catch (IOException e) {\n                throw new BackupException(\"Failed to encrypt checksums.txt\");\n            }\n            // Replace current backup\n            try {\n                mBackupItem.commit();\n            } catch (IOException e) {\n                throw new BackupException(\"Could not finalise backup.\", e);\n            }\n            backupSuccess = true;\n        } catch (BackupException e) {\n            throw e;\n        } catch (Throwable th) {\n            throw new BackupException(\"Unknown error occurred.\", th);\n        } finally {\n            mBackupItem.cleanup();\n            mCachedApk.requireParent().delete();\n            if (backupSuccess) {\n                BackupUtils.putBackupToDbAndBroadcast(ContextUtils.getContext(), mDestMetadata);\n            }\n        }\n    }\n\n    @Override\n    public void cleanup() {\n        for (Path file : mFilesToBeDeleted) {\n            file.delete();\n        }\n    }\n\n    private void backupApkFile() throws BackupException {\n        Path sourceDir = mCachedApk.requireParent();","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/SBConverter.java#L135-L171","documentation":"SBConverter.convert's catch-all converts any Throwable that is not already a BackupException into BackupException('Unknown error occurred.', th). It guarantees callers always receive a BackupException from convert, while the cause retains the original unexpected failure (NPE, ClassCastException, RuntimeException, Error, etc.).","triggerScenarios":"Any unexpected Throwable inside the conversion pipeline not covered by the specific IOException/CryptoException handlers — e.g. NullPointerException on uninitialized fields (mBackupItem, mDestMetadata), ClassCastException, or runtime errors from metadata/icon/APK backup helpers.","commonSituations":"Programming errors in converter state (fields used before assignment), unexpected nulls from parsed source metadata, library bugs, or OOM/other Errors during large APK backups.","solutions":["Inspect the cause (th) stack trace — the message is intentionally generic","Check that all converter fields (mBackupItem, mDestMetadata, mChecksum, mCachedApk) are initialized before use","Re-run with debug logging to find which conversion stage threw","Report/fix the underlying bug; this catch-all indicates an unanticipated failure path"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// guard converter state before calling convert\nif (packageName == null || userId < 0) {\n    throw new IllegalArgumentException(\"packageName and userId must be set before conversion\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    converter.convert(...);\n} catch (BackupException e) {\n    Throwable root = e.getCause();\n    if (root != null) {\n        Log.e(TAG, \"Conversion failed with unexpected error\", root);\n    }\n}","preventionTips":["Always inspect getCause() — the top message is a generic catch-all","Initialize all converter fields before invoking convert","Run conversion in debug mode to capture the original stack trace","Handle large backups carefully to avoid runtime Errors (OOM)"],"tags":["android","backup","unexpected","catch-all"],"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"}