This fixes issue #417 where autoupdate installer files were not deleted on macOS, leading to accumulation of old installers. Key changes: - Store update files in application-specific directory - Clear update files directory on every app launch Other supporting changes: - Refactor file system operations to be more testable and reusable - Improve separation of concerns in directory management - Enhance dependency injection for auto-update logic - Fix async completion to support `await` operations - Add additional logging and revise some log messages during updates
31 lines
587 B
TypeScript
31 lines
587 B
TypeScript
export function collectExceptionMessage(action: () => unknown): string {
|
|
return collectException(action).message;
|
|
}
|
|
|
|
function collectException(
|
|
action: () => unknown,
|
|
): Error {
|
|
let error: Error | undefined;
|
|
try {
|
|
action();
|
|
} catch (err) {
|
|
error = err;
|
|
}
|
|
if (!error) {
|
|
throw new Error('Action did not throw');
|
|
}
|
|
return error;
|
|
}
|
|
|
|
export async function collectExceptionAsync(
|
|
action: () => Promise<unknown>,
|
|
): Promise<Error | undefined> {
|
|
let error: Error | undefined;
|
|
try {
|
|
await action();
|
|
} catch (err) {
|
|
error = err;
|
|
}
|
|
return error;
|
|
}
|