for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
export default class ExtensionErrorService {
static get name() {
return 'extensionErrorService';
}
constructor(errorCodes, fallbackError) {
this.errorCodes = errorCodes;
this.fallbackError = fallbackError;
handleErrorResponse(errorResponse, translator) {
const errors = Shopware.Utils.get(errorResponse, 'response.data.errors', []);
Shopware
/** global: Shopware */
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.
if (!Array.isArray(errors)) {
return [];
return errors.map((error) => {
return this.handleError(error, translator);
});
handleError(error, translator) {
return this._translateRawNotification(
this._getNotification(error, translator),
translator
);
_getNotification(error) {
return this.errorCodes[error.code] ?
this.errorCodes[error.code] :
this.fallbackError;
_translateRawNotification(notification, translator) {
return {
title: translator.$tc(notification.title),
message: translator.$tc(notification.message),
autoClose: notification.autoClose
};
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.