Report failures where the operator can still see them

The 55 alert() calls carried the same suppression as the confirms, and go wrong in the worse
direction: a silenced confirm makes a button do nothing, while a silenced alert lets the action
run and says nothing about it failing. vvAlert returns a promise nobody has to await, so these
converted by rename with no caller becoming async. The icon is inferred from the message rather
than asked of fifty call sites, and an explicit type still wins.
This commit is contained in:
Gmer4Lfe
2026-08-09 21:47:23 -04:00
parent 7d865b0a09
commit e4423200cc
7 changed files with 69 additions and 57 deletions
+14 -2
View File
@@ -147,7 +147,19 @@ function vvConfirm(text, opts) {
}
// Telling the operator something, with no question attached. Returns a promise so a caller can
// sequence on it, but nothing has to await it.
// sequence on it, but nothing has to await it — which is what let the fifty-odd alert() sites
// become this by rename alone, with no function above them turning async.
//
// The icon is read off the message when the caller does not say. Almost every one of these
// reports a failure — "Save failed: …", "Error: …" — and asking fifty call sites to each classify
// themselves would mean fifty chances to disagree about what counts as an error. The caller can
// still pass type explicitly and that always wins.
function vvAlertType(text) {
const s = String(text ?? '');
if (/\b(fail|failed|error|denied|invalid|refused|cannot|could not|unable)\b/i.test(s)) return 'error';
if (/\b(warn|warning|already|must be)\b/i.test(s)) return 'warning';
return 'info';
}
function vvAlert(text, opts) {
const o = opts || {};
return new Promise(function (resolve) {
@@ -155,7 +167,7 @@ function vvAlert(text, opts) {
swal({
title: o.title || '',
text: String(text ?? ''),
type: o.type || 'info',
type: o.type || vvAlertType(text),
confirmButtonText: o.confirmText || 'OK',
}, function (ok) { resolve(true); });
});