MCPcopy
hub / github.com/xintaofei/codeg / toErrorMessage

Function toErrorMessage

src/lib/app-error.ts:84–104  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

82}
83
84export function toErrorMessage(error: unknown): string {
85 const appError = extractAppCommandError(error)
86 if (appError) {
87 return appError.detail?.trim() || appError.message
88 }
89
90 if (error instanceof Error) {
91 return error.message.trim()
92 }
93
94 if (typeof error === "string") {
95 return error.trim()
96 }
97
98 try {
99 const serialized = JSON.stringify(error)
100 return serialized ? serialized.trim() : String(error)
101 } catch {
102 return String(error)
103 }
104}
105
106/** Translator callable shape compatible with next-intl's scoped translator. */
107export type AppErrorTranslator = (

Callers 15

GitLogTabFunction · 0.90
handleCloneFunction · 0.90
CommandManageDialogFunction · 0.90
RemoteWorkspaceDropdownFunction · 0.90
runGitTaskFunction · 0.90
BranchDropdownFunction · 0.90
GitChangesTabFunction · 0.90
handleStashFunction · 0.90
CommitWorkspaceFunction · 0.90
FileTreeTabFunction · 0.90

Calls 1

extractAppCommandErrorFunction · 0.85

Tested by

no test coverage detected