MCPcopy Create free account
hub / github.com/su-kaka/gcli2api / toggleErrorDetailsCommon

Function toggleErrorDetailsCommon

front/common.js:1946–2093  ·  view source on GitHub ↗
(pathId, manager)

Source from the content-addressed store, hash-verified

1944}
1945
1946async function toggleErrorDetailsCommon(pathId, manager) {
1947 const errorDetails = document.getElementById('errors-' + pathId);
1948 if (!errorDetails) return;
1949
1950 // 切换显示状态
1951 const isShowing = errorDetails.classList.toggle('show');
1952
1953 if (isShowing) {
1954 const contentDiv = errorDetails.querySelector('.cred-content');
1955 const filename = contentDiv.getAttribute('data-filename');
1956
1957 // 每次展开都重新加载数据
1958 if (filename) {
1959 contentDiv.innerHTML = '<div style="text-align: center; padding: 20px; color: #666;">⏳ 正在加载报错信息...</div>';
1960
1961 try {
1962 const modeParam = manager.type === 'antigravity' ? 'mode=antigravity' : 'mode=geminicli';
1963 const response = await fetch(`./creds/errors/${encodeURIComponent(filename)}?${modeParam}`, {
1964 method: 'GET',
1965 headers: getAuthHeaders()
1966 });
1967 const data = await response.json();
1968
1969 if (response.ok) {
1970 const errorCodes = data.error_codes || [];
1971 const errorMessages = data.error_messages || {};
1972
1973 if (errorCodes.length === 0) {
1974 contentDiv.innerHTML = `
1975 <div style="text-align: center; padding: 20px; color: #28a745;">
1976 <div style="font-size: 48px; margin-bottom: 10px;">✅</div>
1977 <div style="font-weight: bold;">无报错记录</div>
1978 <div style="font-size: 12px; color: #666; margin-top: 8px;">该凭证运行正常</div>
1979 </div>
1980 `;
1981 } else {
1982 let errorHTML = '';
1983
1984 // 遍历所有错误码,从 errorMessages 对象中获取对应消息
1985 errorCodes.forEach((errorCode) => {
1986 const messageStr = errorMessages[errorCode] || '无详细信息';
1987
1988 // 提取核心错误消息和详细信息
1989 let displayMsg = messageStr;
1990 let detailsHtml = '';
1991
1992 try {
1993 // 尝试解析 JSON 格式的 message
1994 const parsedMsg = JSON.parse(messageStr);
1995 if (parsedMsg.error) {
1996 // 显示核心错误信息
1997 if (parsedMsg.error.message) {
1998 displayMsg = parsedMsg.error.message;
1999 }
2000
2001 // 如果有 details 字段,也显示出来
2002 if (parsedMsg.error.details && Array.isArray(parsedMsg.error.details)) {
2003 detailsHtml = '<div style="margin-top: 10px; padding-top: 10px; border-top: 1px dashed #ddd;">';

Callers 2

toggleErrorDetailsFunction · 0.85

Calls 4

getAuthHeadersFunction · 0.85
highlightHttpLinksFunction · 0.85
escapeHtmlFunction · 0.85
showStatusFunction · 0.85

Tested by

no test coverage detected