mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	Label printing errors (#6450)
* Enhance error handling for label printing * Better feedback in forms * Raise error to user - no need to log
This commit is contained in:
		| @@ -4,6 +4,7 @@ from django.core.exceptions import FieldError, ValidationError | ||||
| from django.http import JsonResponse | ||||
| from django.urls import include, path, re_path | ||||
| from django.utils.decorators import method_decorator | ||||
| from django.utils.translation import gettext_lazy as _ | ||||
| from django.views.decorators.cache import cache_page, never_cache | ||||
|  | ||||
| from django_filters.rest_framework import DjangoFilterBackend | ||||
| @@ -13,6 +14,7 @@ from rest_framework.request import clone_request | ||||
|  | ||||
| import build.models | ||||
| import common.models | ||||
| import InvenTree.exceptions | ||||
| import InvenTree.helpers | ||||
| import label.models | ||||
| import label.serializers | ||||
| @@ -232,9 +234,14 @@ class LabelPrintMixin(LabelFilterMixin): | ||||
|         # At this point, we offload the label(s) to the selected plugin. | ||||
|         # The plugin is responsible for handling the request and returning a response. | ||||
|  | ||||
|         result = plugin.print_labels( | ||||
|             label, items_to_print, request, printing_options=request.data | ||||
|         ) | ||||
|         try: | ||||
|             result = plugin.print_labels( | ||||
|                 label, items_to_print, request, printing_options=request.data | ||||
|             ) | ||||
|         except ValidationError as e: | ||||
|             raise (e) | ||||
|         except Exception as e: | ||||
|             raise ValidationError([_('Error printing label'), str(e)]) | ||||
|  | ||||
|         if isinstance(result, JsonResponse): | ||||
|             result['plugin'] = plugin.plugin_slug() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user