fix desktop gui error handling for workers (#2538)

This commit is contained in:
Neal Shah
2026-02-24 16:32:14 -05:00
committed by GitHub
parent 1e3193366a
commit 267713481c
+20 -18
View File
@@ -103,10 +103,12 @@ async function UIWindowPublishWorker (target_dir_uid, target_dir_name, target_di
const sandboxed = $(el_window).find('.publish-worker-sandboxed').is(':checked');
const createOptions = sandboxed ? { sandbox: true } : { sandbox: false };
puter.workers.create(worker_name,
target_dir_path,
createOptions).then((res) => {
let url = `https://${ worker_name }.puter.work`;
puter.workers.create(
worker_name,
target_dir_path,
createOptions,
).then((res) => {
let url = `https://${ worker_name }.puter.work`;
$(el_window).find('.window-publishWorker-form').hide(100, function () {
$(el_window).find('.publishWorker-published-link').attr('href', url);
$(el_window).find('.publishWorker-published-link').text(url);
@@ -121,25 +123,25 @@ async function UIWindowPublishWorker (target_dir_uid, target_dir_name, target_di
// update item's website_url attribute
// $(this).attr('data-website_url', url + $(this).attr('data-path').substring(target_dir_path.length));
});
}).catch((err) => {
let errorHtml;
// Handle worker service errors (result.success === false)
if ( ! (err instanceof Error) ) {
// Handle regular API errors
const error = err.error || err;
errorHtml = error.message + (
error.code === 'subdomain_limit_reached' ?
` <span class="manage-your-websites-link">${ i18n('manage_your_subdomains') }</span>` : ''
);
} else {
errorHtml = `<pre style="white-space: pre-wrap; font-family: monospace; font-size: 12px; margin: 0; text-align: left; font-family: monospace;">${html_encode(err)}</pre>`;
}
}).catch((err) => {
let errorHtml;
// Handle worker service errors (result.success === false)
if ( ! (err instanceof Error) ) {
// Handle regular API errors
const error = err.error || err;
errorHtml = error.message + (
error.code === 'subdomain_limit_reached' ?
` <span class="manage-your-websites-link">${ i18n('manage_your_subdomains') }</span>` : ''
);
} else {
errorHtml = `<pre style="white-space: pre-wrap; font-family: monospace; font-size: 12px; margin: 0; text-align: left; font-family: monospace;">${html_encode(err.message)}</pre>`;
}
$(el_window).find('.publish-worker-error-msg').html(errorHtml);
$(el_window).find('.publish-worker-error-msg').fadeIn();
// re-enable 'Publish' button and restore original text
$(el_window).find('.publish-btn').prop('disabled', false).text(originalText);
});
});
});
$(el_window).find('.publish-window-ok-btn').on('click', function () {