Exceptions — Aspose.Note FOSS for Python API Reference
Cây phân cấp ngoại lệ
Tất cả các ngoại lệ có thể được nhập trực tiếp từ aspose.note:
from aspose.note import (
AsposeNoteError,
FileCorruptedException,
IncorrectDocumentStructureException,
IncorrectPasswordException,
UnsupportedFileFormatException,
UnsupportedSaveFormatException,
)Cây kế thừa:
Exception
└── AsposeNoteError
├── FileCorruptedException
├── IncorrectDocumentStructureException
├── IncorrectPasswordException
├── UnsupportedFileFormatException
└── UnsupportedSaveFormatExceptionAsposeNoteError
Enumerations: from aspose.note import AsposeNoteError Enumerations: Exception
Lớp cơ sở cho tất cả các ngoại lệ FOSS Aspose.Note. Bắt lớp này để xử lý bất kỳ lỗi nào của thư viện bất kể nguyên nhân cụ thể.
from aspose.note import Document, AsposeNoteError
try:
doc = Document("unknown.one")
except AsposeNoteError as e:
print(f"Aspose.Note error: {e}")FileCorruptedException
Enumerations: from aspose.note import FileCorruptedException Enumerations: AsposeNoteError
Được ném ra khi .one tệp không thể được phân tích vì cấu trúc nhị phân của nó bị hỏng hoặc sai dạng.
Khi được ném
- Được ném ra bởi
Document.__init__khi bộ phân tích tệp gặp lỗi nhị phân không thể khôi phục.
Enumerations
from aspose.note import Document, FileCorruptedException
try:
doc = Document("corrupted.one")
except FileCorruptedException as e:
print(f"File is corrupted: {e}")IncorrectDocumentStructureException
Enumerations: from aspose.note import IncorrectDocumentStructureException Enumerations: AsposeNoteError
Được ném ra khi cấu trúc tệp được nhận dạng là một .one tệp nhưng chứa cấu trúc nội bộ không hợp lệ hoặc không được hỗ trợ.
Khi được ném
- Được ném ra bởi
Document.__init__khi tệp vượt qua các kiểm tra định dạng cơ bản nhưng có các vấn đề cấu trúc ngăn cản việc tải.
Enumerations
from aspose.note import Document, IncorrectDocumentStructureException
try:
doc = Document("unusual.one")
except IncorrectDocumentStructureException as e:
print(f"Document structure error: {e}")IncorrectPasswordException
Enumerations: from aspose.note import IncorrectPasswordException Enumerations: AsposeNoteError
Được ném khi LoadOptions.DocumentPassword được thiết lập. Các tài liệu được mã hóa (bảo vệ bằng mật khẩu) không được hỗ trợ trong v26.3.1.
Khi được ném
- Được ném bởi
Document.__init__khiload_options.DocumentPasswordkhông phảiNone.
Enumerations
from aspose.note import Document, LoadOptions, IncorrectPasswordException
opts = LoadOptions()
opts.DocumentPassword = "secret"
try:
doc = Document("protected.one", opts)
except IncorrectPasswordException as e:
print(f"Encryption not supported: {e}")UnsupportedFileFormatException
Enumerations: from aspose.note import UnsupportedFileFormatException Enumerations: AsposeNoteError
Được ném khi định dạng tệp không được nhận dạng là một .one tệp. Tiết lộ một FileFormat thuộc tính (một chuỗi) với định danh định dạng đã được phát hiện hoặc đã cố gắng.
Enumerations
| Enumerations | Enumerations | Enumerations |
|---|---|---|
FileFormat | `str | None` |
Khi được ném
- Được ném bởi
Document.__init__khi bộ phân tích không thể xác định tệp là định dạng OneNote được hỗ trợ.
Enumerations
from aspose.note import Document, UnsupportedFileFormatException
try:
doc = Document("notatonenote.xlsx")
except UnsupportedFileFormatException as e:
print(f"Unsupported format: {e}")
if e.FileFormat:
print(f"Detected format: {e.FileFormat}")UnsupportedSaveFormatException
Enumerations: from aspose.note import UnsupportedSaveFormatException Enumerations: AsposeNoteError
Phát sinh khi Document.Save() được gọi với một SaveFormat hoặc lớp tùy chọn không được triển khai trong v26.3.1. Chỉ SaveFormat.Pdf được triển khai; tất cả các định dạng khác sẽ ném ngoại lệ này.
Khi được ném
Document.Save(target, SaveFormat.One)— Định dạng vòng quay OneNote được khai báo nhưng chưa được triển khaiDocument.Save(target, ...)sử dụng bất kỳSaveOptionslớp con không phải làPdfSaveOptions
Enumerations
from aspose.note import Document, SaveFormat, UnsupportedSaveFormatException
doc = Document("MyNotes.one")
try:
doc.Save("output.one", SaveFormat.One)
except UnsupportedSaveFormatException as e:
print(f"Save format not supported: {e}")Bắt tất cả lỗi tải
from aspose.note import (
Document,
FileCorruptedException,
IncorrectDocumentStructureException,
IncorrectPasswordException,
UnsupportedFileFormatException,
)
def safe_load(path: str) -> Document | None:
try:
return Document(path)
except FileCorruptedException:
print(f"{path}: file is corrupted")
except IncorrectDocumentStructureException:
print(f"{path}: invalid document structure")
except IncorrectPasswordException:
print(f"{path}: encrypted documents are not supported")
except UnsupportedFileFormatException:
print(f"{path}: format not recognized")
return NoneBắt tất cả lỗi lưu
from aspose.note import (
Document, SaveFormat, UnsupportedSaveFormatException
)
doc = Document("MyNotes.one")
try:
doc.Save("output.pdf", SaveFormat.Pdf)
except UnsupportedSaveFormatException as e:
print(f"Cannot save: {e}")Xem Thêm
- Enumerations: hàm khởi tạo ném ngoại lệ tải;
Save()némUnsupportedSaveFormatException - LoadOptions: thiết lập
DocumentPasswordkích hoạtIncorrectPasswordException - SaveFormat: chỉ
SaveFormat.Pdfđược triển khai trong v26.3.1