Skip to content

Commit cb512ce

Browse files
committed
fix(projects): show server error detail when adding a project fails
- The alert now includes the specific error message from the server - Previously showed a generic string regardless of the actual failure reason
1 parent 782a73b commit cb512ce

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

static/js/projects.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,27 @@ async function _addCurrentProject() {
226226
const name = await showInputModal('プロジェクトを保存', 'プロジェクト名', suggested);
227227
if (!name) return;
228228

229-
await fetch('/api/grepnavi', {
229+
const gnRes = await fetch('/api/grepnavi', {
230230
method: 'POST',
231231
headers: { 'Content-Type': 'application/json' },
232232
body: JSON.stringify({ root, graph: graphPath }),
233233
});
234+
if (!gnRes.ok) {
235+
const gnErr = await gnRes.json().catch(() => ({}));
236+
alert('.grepnaviの書き込みに失敗しました: ' + (gnErr.error || gnRes.status));
237+
return;
238+
}
234239

235240
const res = await fetch('/api/projects', {
236241
method: 'POST',
237242
headers: { 'Content-Type': 'application/json' },
238243
body: JSON.stringify({ name, grepnaviFile: gnPath }),
239244
});
240-
if (!res.ok) { alert('保存に失敗しました'); return; }
245+
if (!res.ok) {
246+
const err = await res.json().catch(() => ({}));
247+
alert('保存に失敗しました: ' + (err.error || res.status));
248+
return;
249+
}
241250
_projectsData = await res.json();
242251
const added = _projectsData.find(p => (p.grepnaviFile || '').replace(/\\/g, '/') === gnPath);
243252
if (added) _expandedProjects.add(added.id);

0 commit comments

Comments
 (0)