Refactor decryption logic to handle empty fields consistently across services
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
/**
|
||||
* Clean error messages from Electron IPC prefix
|
||||
* Transforms: "Error invoking remote method 'channel': Error: Message"
|
||||
* Into: "Message"
|
||||
* Extract user-facing error message from various error formats.
|
||||
* Supports: Error objects, Tauri AppError { kind, message }, and plain strings.
|
||||
*/
|
||||
export function cleanErrorMessage(error: unknown): string {
|
||||
if (error instanceof Error) {
|
||||
return error.message.replace(/^Error invoking remote method '[^']+': Error: /, '');
|
||||
return error.message;
|
||||
}
|
||||
if (typeof error === 'object' && error !== null && 'message' in error) {
|
||||
return String((error as { message: string }).message);
|
||||
}
|
||||
if (typeof error === 'string') {
|
||||
return error.replace(/^Error invoking remote method '[^']+': Error: /, '');
|
||||
return error;
|
||||
}
|
||||
return 'An unknown error occurred';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user