Improve error handling for label printing [SCI-10039] (#6997)

This commit is contained in:
ajugo 2024-01-31 11:10:11 +01:00 committed by GitHub
parent edce20e303
commit 9d48cbbb86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 4 deletions

View file

@ -1,6 +1,6 @@
/* eslint-disable no-param-reassign */
/* eslint-disable no-undef */
/* global I18n */
/* global HelperModule I18n */
/* eslint-disable no-unused-vars, no-use-before-define */
/* config = {
@ -218,6 +218,8 @@ var zebraPrint = (function() {
updateProgressModalData(progressModal, printData.printer_name, PRINTER_STATUS_ERROR, PRINTER_STATUS_ERROR);
}
});
}).fail(() => {
HelperModule.flashAlertMsg(I18n.t('repository_row.modal_print_label.general_error'), 'danger');
});
}
};

View file

@ -91,6 +91,8 @@
</template>
<script>
/* global HelperModule */
import DropdownSelector from '../shared/dropdown_selector.vue';
import LabelPreview from '../label_template/components/label_preview.vue';
@ -203,8 +205,14 @@ export default {
this.labelTemplateError = null;
this.labelTemplateCode = result.label_code;
}).fail((result) => {
this.labelTemplateError = result.responseJSON.error;
this.labelTemplateCode = result.responseJSON.label_code;
if (result.responseJSON) {
this.labelTemplateError = result.responseJSON.error;
this.labelTemplateCode = result.responseJSON.label_code;
} else {
this.labelTemplateError = null;
this.labelTemplateCode = null;
HelperModule.flashAlertMsg(this.i18n.t('repository_row.modal_print_label.general_error'), 'danger');
}
});
},
submitPrint() {
@ -233,6 +241,8 @@ export default {
$(this.$refs.modal).modal('hide');
this.$emit('close');
PrintProgressModal.init(data);
}).fail(() => {
HelperModule.flashAlertMsg(this.i18n.t('repository_row.modal_print_label.general_error'), 'danger');
});
}
});

View file

@ -17,7 +17,7 @@ module LabelTemplates
errors = []
keys = @label_template.content.scan(/(?<=\{\{).*?(?=\}\})/).uniq
label = keys.reduce(@label_template.content.dup) do |rendered_content, key|
rendered_content.gsub!(/\{\{#{key}\}\}/, fetch_value(key))
rendered_content.gsub!(Regexp.new(Regexp.escape("{{#{key}}}")), fetch_value(key))
rescue LabelTemplates::ColumnNotFoundError,
LabelTemplates::LogoNotFoundError,
LabelTemplates::LogoParamsError => e

View file

@ -2584,6 +2584,7 @@ en:
title: "There seems to be no printer available"
description: "To learn more about printing labels and label printers please visit our blog."
visit_blog: "Visit blog"
general_error: "Something went wrong"
reminder:
clear: "Clear"
low_stock_title: "Item running low"