mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Raise exceptions instead of returning error strings in edit_pdf
This commit is contained in:
		| @@ -532,7 +532,7 @@ def edit_pdf( | ||||
|                 logger.error( | ||||
|                     "Update requested but multiple output documents specified", | ||||
|                 ) | ||||
|                 return "ERROR" | ||||
|                 raise ValueError("Multiple output documents specified") | ||||
|  | ||||
|             for op in operations: | ||||
|                 dst = pdf_docs[op.get("doc", 0)] | ||||
| @@ -583,7 +583,9 @@ def edit_pdf( | ||||
|  | ||||
|     except Exception as e: | ||||
|         logger.exception(f"Error editing document {doc.id}: {e}") | ||||
|         return "ERROR" | ||||
|         raise ValueError( | ||||
|             f"An error occurred while editing the document: {e}", | ||||
|         ) from e | ||||
|  | ||||
|     return "OK" | ||||
|  | ||||
|   | ||||
| @@ -1032,8 +1032,8 @@ class TestPDFActions(DirectoriesMixin, TestCase): | ||||
|             {"page": 9999},  # invalid page, forces error during PDF load | ||||
|         ] | ||||
|         with self.assertLogs("paperless.bulk_edit", level="ERROR"): | ||||
|             result = bulk_edit.edit_pdf(doc_ids, operations) | ||||
|             self.assertEqual(result, "ERROR") | ||||
|             with self.assertRaises(Exception): | ||||
|                 bulk_edit.edit_pdf(doc_ids, operations) | ||||
|         mock_group.assert_not_called() | ||||
|         mock_consume_file.assert_not_called() | ||||
|  | ||||
| @@ -1058,7 +1058,7 @@ class TestPDFActions(DirectoriesMixin, TestCase): | ||||
|             {"page": 2, "doc": 1}, | ||||
|         ] | ||||
|         with self.assertLogs("paperless.bulk_edit", level="ERROR"): | ||||
|             result = bulk_edit.edit_pdf(doc_ids, operations, update_document=True) | ||||
|             self.assertEqual(result, "ERROR") | ||||
|             with self.assertRaises(ValueError): | ||||
|                 bulk_edit.edit_pdf(doc_ids, operations, update_document=True) | ||||
|         mock_group.assert_not_called() | ||||
|         mock_consume_file.assert_not_called() | ||||
|   | ||||
| @@ -1427,7 +1427,6 @@ class BulkEditView(PassUserMixin): | ||||
|                     ) | ||||
|                 } | ||||
|  | ||||
|             # TODO: parameter validation | ||||
|             result = method(documents, **parameters) | ||||
|  | ||||
|             if settings.AUDIT_LOG_ENABLED and modified_field: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon