Skip to content

Commit 31b6a9e

Browse files
committed
MC-5691: Implement better developer error reporting
- Ensure promises console out any errors generated within
1 parent 52f5ab6 commit 31b6a9e

File tree

16 files changed

+6160
-299
lines changed

16 files changed

+6160
-299
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/column-group/factory.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/preview.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/master-format/render.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/panel.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/stage-builder.js

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/stage.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/column-group/factory.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,8 @@ export function createColumn(
2929
).then((column: ContentTypeCollectionInterface<ColumnPreview>) => {
3030
parent.addChild(column, index);
3131
return column;
32+
}).catch((error) => {
33+
console.error(error);
34+
return null;
3235
});
3336
}

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/preview.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ export default class Preview {
312312
contentType: ContentTypeInterface | ContentTypeCollectionInterface,
313313
autoAppend: boolean = true,
314314
direct: boolean = false,
315-
): Promise<ContentTypeInterface> | void {
315+
): Promise<ContentTypeInterface> {
316316
const contentTypeData = contentType.dataStore.get() as DataObject;
317317
const index = contentType.parent.getChildren()().indexOf(contentType) + 1 || null;
318318

@@ -331,6 +331,9 @@ export default class Preview {
331331

332332
resolve(duplicateContentType);
333333
});
334+
}).catch((error) => {
335+
console.error(error);
336+
return null;
334337
});
335338
}
336339

@@ -461,14 +464,14 @@ export default class Preview {
461464
/**
462465
* Dispatch content type clone events
463466
*
464-
* @param {ContentTypeInterface} originalContentType
465-
* @param {ContentTypeInterface} duplicateContentType
467+
* @param {ContentTypeInterface | ContentTypeCollectionInterface} originalContentType
468+
* @param {ContentTypeInterface | ContentTypeCollectionInterface} duplicateContentType
466469
* @param {number} index
467470
* @param {boolean} direct
468471
*/
469472
protected dispatchContentTypeCloneEvents(
470-
originalContentType: ContentTypeInterface,
471-
duplicateContentType: ContentTypeInterface,
473+
originalContentType: ContentTypeInterface | ContentTypeCollectionInterface,
474+
duplicateContentType: ContentTypeInterface | ContentTypeCollectionInterface,
472475
index: number,
473476
direct: boolean,
474477
) {

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/master-format/render.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export default class MasterFormatRenderer {
3838
},
3939
},
4040
);
41+
}).catch((error) => {
42+
console.error(error);
43+
return null;
4144
});
4245
}
4346
}

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/panel.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* See COPYING.txt for license details.
44
*/
55

6+
import consoleLogger from "consoleLogger";
67
import $ from "jquery";
78
import ko from "knockout";
89
import $t from "mage/translate";
@@ -268,7 +269,8 @@ export default class Panel implements PanelInterface {
268269
}
269270

270271
} else {
271-
console.warn("Configuration is not properly initialized, please check the Ajax response.");
272+
consoleLogger.error("Unable to retrieve content types from server, please inspect network requests " +
273+
"response.");
272274
}
273275
}
274276
}

0 commit comments

Comments
 (0)