Skip to content

Commit

Permalink
Merge pull request #896 from adobecom/MWPW-162674
Browse files Browse the repository at this point in the history
MWPW-162674: Adding properties available to Lana Logs for unity error handling
  • Loading branch information
joaquinrivero authored Nov 19, 2024
2 parents d1718ce + 8f684bd commit 0fd8344
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions acrobat/blocks/verb-widget/verb-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,19 @@ export default async function init(element) {
tags: 'DC_Milo,Project Unity (DC)',
};

const handleError = (str, logToLana = false, logOptions = {}, e = null) => {
const handleError = (detail, logToLana = false, logOptions = {}) => {
const { code, message, status, info = 'No additional info provided', accountType = 'Unknown account type' } = detail;

setDraggingClass(widget, false);
errorState.classList.add('verb-error');
errorState.classList.remove('hide');
errorStateText.textContent = str;
errorStateText.textContent = message;

if (logToLana && e) {
const status = e.detail?.status || 'Unknown status';
const message = e.detail?.message || 'Unknown message';
window.lana?.log(`Error Status: ${status}, Error Message: ${message}`, logOptions);
if (logToLana) {
window.lana?.log(
`Error Code: ${code}, Status: ${status}, Message: ${message}, Info: ${info}, Account Type: ${accountType}`,
logOptions,
);
}

setTimeout(() => {
Expand All @@ -303,35 +306,35 @@ export default async function init(element) {

element.addEventListener('unity:show-error-toast', (e) => {
if (e.detail?.code.includes('error_only_accept_one_file')) {
handleError(e.detail?.message, true, lanaOptions, e);
handleError(e.detail, true, lanaOptions);
verbAnalytics('error', VERB);
}

if (e.detail?.code.includes('error_unsupported_type')) {
handleError(e.detail?.message, true, lanaOptions, e);
handleError(e.detail, true, lanaOptions);
verbAnalytics('error:unsupported_type', VERB);
}

if (e.detail?.code.includes('error_empty_file')) {
handleError(e.detail?.message, true, lanaOptions, e);
handleError(e.detail, true, lanaOptions);
verbAnalytics('error:empty_file', VERB);
}

if (e.detail?.code.includes('error_file_too_large')) {
handleError(e.detail?.message, true, lanaOptions, e);
handleError(e.detail, true, lanaOptions);
verbAnalytics('error', VERB);
}

if (e.detail?.code.includes('error_max_page_count')) {
handleError(e.detail?.message, true, lanaOptions, e);
handleError(e.detail, true, lanaOptions);
verbAnalytics('error:max_page_count', VERB);
}

if (e.detail?.code.includes('error_generic')
|| e.detail?.code.includes('error_max_quota_exceeded')
|| e.detail?.code.includes('error_no_storage_provision')
|| e.detail?.code.includes('error_duplicate_asset')) {
handleError(e.detail?.message, true, lanaOptions, e);
handleError(e.detail, true, lanaOptions);
verbAnalytics('error', VERB);
}

Expand Down

0 comments on commit 0fd8344

Please sign in to comment.