refactor: Accept unknown in errorToConsole to drop as Error casts (#2541)

This commit is contained in:
Dermot Duffy
2026-06-30 17:45:13 -07:00
committed by dermotduffy
parent fcef48e75a
commit 95f35bd326
19 changed files with 32 additions and 27 deletions
+5 -5
View File
@@ -76,13 +76,13 @@ export function contentsChanged(
/**
* Log an error as a warning to the console.
* @param e The Error-like object.
* @param e The caught error or error-like value.
* @param func The Console func to call.
*/
export function errorToConsole(
e: Error | { message: unknown } | string,
func: CallableFunction = console.warn,
): void {
export function errorToConsole(e: unknown, func: CallableFunction = console.warn): void {
if (!e) {
return;
}
if (e instanceof AdvancedCameraCardError && e.context) {
func(e, e.context);
} else if (typeof e === 'object' && 'message' in e) {
+3 -3
View File
@@ -19,7 +19,7 @@ export async function toggleReviewed(
try {
await viewItemManager.reviewMedia(item, newState);
} catch (e) {
errorToConsole(e as Error);
errorToConsole(e);
return false;
}
item.setReviewed(newState);
@@ -55,7 +55,7 @@ export async function toggleFavorite(
try {
await viewItemManager.favorite(item, newState);
} catch (e) {
errorToConsole(e as Error);
errorToConsole(e);
return false;
}
return true;
@@ -72,7 +72,7 @@ export async function downloadMedia(
try {
await viewItemManager.download(item);
} catch (e) {
errorToConsole(e as Error);
errorToConsole(e);
return false;
}
return true;
+1 -1
View File
@@ -30,7 +30,7 @@ export const renderTask = <R>(
pending: () =>
options?.inProgressFunc?.() ?? renderProgressIndicator(progressConfig),
error: (e: unknown) => {
errorToConsole(e as Error);
errorToConsole(e);
return options?.errorFunc?.(e as Error);
},
complete: completeFunc,