MCPcopy
hub / github.com/HisMax/RedInk / legacyMessageToError

Function legacyMessageToError

frontend/src/utils/errors.ts:80–101  ·  view source on GitHub ↗
(
  message: string,
  fallbackTitle = '操作失败',
  status = 500,
  suggestion?: string
)

Source from the content-addressed store, hash-verified

78}
79
80function legacyMessageToError(
81 message: string,
82 fallbackTitle = '操作失败',
83 status = 500,
84 suggestion?: string
85): AppError {
86 const clean = message || '发生未知错误'
87 const firstLine = clean.split('\n').map(line => line.trim()).find(Boolean) || fallbackTitle
88
89 return {
90 type: `https://redink.app/errors/${inferCode(clean).toLowerCase().replace(/_/g, '-')}`,
91 code: inferCode(clean),
92 title: inferTitle(clean, fallbackTitle),
93 detail: firstLine,
94 suggestion: suggestion || inferSuggestion(clean),
95 status: status || 500,
96 retryable: inferRetryable(clean),
97 diagnostics: {
98 raw: clean
99 }
100 }
101}
102
103function inferCode(message: string): string {
104 const text = message.toLowerCase()

Callers 1

normalizeApiErrorFunction · 0.85

Calls 4

inferCodeFunction · 0.85
inferTitleFunction · 0.85
inferSuggestionFunction · 0.85
inferRetryableFunction · 0.85

Tested by

no test coverage detected