mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
Enables @typescript-eslint/no-unsafe-member-access globally. Tests and 41 heavy source files (>5 violations each) are exempted via per-file overrides with current violation counts annotated for follow-up PRs. Fixes 124 violations across 51 source files using narrow type assertions, instanceof Error guards, and proper structural types instead of blanket any casts. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
17 lines
608 B
TypeScript
17 lines
608 B
TypeScript
export function err2String(err: unknown, stack = false): string {
|
|
try {
|
|
if (err instanceof Error) {
|
|
const cause = (err as { cause?: unknown }).cause;
|
|
const causeMsg = cause instanceof Error ? cause.message : cause ? String(cause as any) : "";
|
|
const stackStr = stack && err.stack ? err.stack : "";
|
|
const parts = [err.message];
|
|
if (causeMsg) parts.push(`more message: ${causeMsg}`);
|
|
if (stackStr) parts.push(stackStr);
|
|
return parts.join("\n");
|
|
}
|
|
const json = JSON.stringify(err);
|
|
return json ?? String(err);
|
|
} catch {
|
|
return String(err);
|
|
}
|
|
}
|