diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 351348c6bc..32a93f5452 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -818,13 +818,22 @@ class BomExtractSerializer(serializers.Serializer): raise serializers.ValidationError(_("File is too large")) # Read file data into memory (bytes object) - data = bom_file.read() + try: + data = bom_file.read() + except Exception as e: + raise serializers.ValidationError(str(e)) if ext in ['csv', 'tsv', 'xml']: - data = data.decode() + try: + data = data.decode() + except Exception as e: + raise serializers.ValidationError(str(e)) # Convert to a tablib dataset (we expect headers) - self.dataset = tablib.Dataset().load(data, ext, headers=True) + try: + self.dataset = tablib.Dataset().load(data, ext, headers=True) + except Exception as e: + raise serializers.ValidationError(str(e)) for header in self.REQUIRED_COLUMNS: