Make admin and API errors visible and traceable
Return structured JSON errors with request IDs, log unexpected exceptions with tracebacks, and show HTTP and network failures in the admin UI without losing unsaved source. Preserve publication errors when release listing also fails, handle cancelled preview promises, and add regression tests, browser failure scenarios, and updated API documentation.
This commit is contained in:
@@ -44,7 +44,10 @@
|
||||
revision:current.rev, mode:current.mode, selection:current.selection, readonly:current.readonlySelection};}
|
||||
function requestPreview() {
|
||||
if (!current || !window.htmx || current.busy || one('#editor-result')?.dataset.valid !== '1') return;
|
||||
htmx.ajax('POST', '/admin/editor' + current.root.dataset.base + '/preview', {target:'#preview-result', swap:'outerHTML', values:params()});
|
||||
const state=current;
|
||||
htmx.ajax('POST', '/admin/editor' + current.root.dataset.base + '/preview', {target:'#preview-result', swap:'outerHTML', values:params()}).catch(()=>{
|
||||
if(current===state && state.root.isConnected) notice('Превью недоступно. Правки остаются в редакторе.');
|
||||
});
|
||||
}
|
||||
function formValues(form, submitter) {
|
||||
const data=new FormData(form), values={};
|
||||
@@ -172,7 +175,10 @@
|
||||
if(current.inspectorDirty||current.busy){notice('Сначала примените изменения инспектора.');return;}
|
||||
current.selection=block.scope==='page'?block.id:'';
|
||||
current.readonlySelection=block.scope==='page'?'':JSON.stringify(block);
|
||||
htmx.ajax('POST','/admin/editor'+current.root.dataset.base+'/select',{target:'#editor-result',swap:'outerHTML',values:params()});
|
||||
const state=current;
|
||||
htmx.ajax('POST','/admin/editor'+current.root.dataset.base+'/select',{target:'#editor-result',swap:'outerHTML',values:params()}).catch(()=>{
|
||||
if(current===state && state.root.isConnected) notice('Не удалось выбрать блок. Правки остаются в редакторе.');
|
||||
});
|
||||
}
|
||||
function passivePreview(frame) {
|
||||
const state=current,p=state?.preview;
|
||||
|
||||
Reference in New Issue
Block a user