Exceptions — Aspose.Note FOSS for Python API Reference
ลำดับชั้นของข้อยกเว้น
ข้อยกเว้นทั้งหมดสามารถนำเข้าโดยตรงจาก aspose.note:
from aspose.note import (
AsposeNoteError,
FileCorruptedException,
IncorrectDocumentStructureException,
IncorrectPasswordException,
UnsupportedFileFormatException,
UnsupportedSaveFormatException,
)ต้นไม้การสืบทอด:
Exception
└── AsposeNoteError
├── FileCorruptedException
├── IncorrectDocumentStructureException
├── IncorrectPasswordException
├── UnsupportedFileFormatException
└── UnsupportedSaveFormatExceptionAsposeNoteError
Properties: from aspose.note import AsposeNoteError Properties: Exception
คลาสฐานสำหรับข้อยกเว้น FOSS Aspose.Note ทั้งหมด ดักจับคลาสนี้เพื่อจัดการข้อผิดพลาดของไลบรารีใด ๆ ไม่ว่าจะมีสาเหตุเฉพาะใด.
from aspose.note import Document, AsposeNoteError
try:
doc = Document("unknown.one")
except AsposeNoteError as e:
print(f"Aspose.Note error: {e}")FileCorruptedException
Properties: from aspose.note import FileCorruptedException Properties: AsposeNoteError
เกิดขึ้นเมื่อ .one ไฟล์ไม่สามารถแยกวิเคราะห์ได้เนื่องจากโครงสร้างไบนารีของมันเสียหายหรือรูปแบบไม่ถูกต้อง.
เมื่อเกิดขึ้น
- เกิดขึ้นโดย
Document.__init__เมื่อโปรแกรมแยกวิเคราะห์ไฟล์พบข้อผิดพลาดไบนารีที่ไม่สามารถกู้คืนได้.
Properties
from aspose.note import Document, FileCorruptedException
try:
doc = Document("corrupted.one")
except FileCorruptedException as e:
print(f"File is corrupted: {e}")IncorrectDocumentStructureException
Properties: from aspose.note import IncorrectDocumentStructureException Properties: AsposeNoteError
เกิดขึ้นเมื่อโครงสร้างไฟล์ถูกระบุว่าเป็น .one ไฟล์แต่มีโครงสร้างภายในที่ไม่ถูกต้องหรือไม่รองรับ.
เมื่อเกิดขึ้น
- เกิดขึ้นโดย
Document.__init__เมื่อไฟล์ผ่านการตรวจสอบรูปแบบพื้นฐานแล้วแต่มีปัญหาโครงสร้างที่ทำให้ไม่สามารถโหลดได้.
Properties
from aspose.note import Document, IncorrectDocumentStructureException
try:
doc = Document("unusual.one")
except IncorrectDocumentStructureException as e:
print(f"Document structure error: {e}")IncorrectPasswordException
Properties: from aspose.note import IncorrectPasswordException Properties: AsposeNoteError
เกิดขึ้นเมื่อ LoadOptions.DocumentPassword ถูกตั้งค่าแล้ว เอกสารที่เข้ารหัส (ป้องกันด้วยรหัสผ่าน) ไม่รองรับใน v26.3.1.
เมื่อเกิดขึ้น
- เกิดขึ้นโดย
Document.__init__เมื่อload_options.DocumentPasswordไม่ใช่None.
Properties
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
Properties: from aspose.note import UnsupportedFileFormatException Properties: AsposeNoteError
เกิดขึ้นเมื่อรูปแบบไฟล์ไม่ถูกจดจำว่าเป็นรูปแบบที่ถูกต้อง .one ไฟล์. เปิดเผย FileFormat แอตทริบิวต์ (เป็นสตริง) ที่มีตัวระบุรูปแบบที่ตรวจพบหรือพยายามใช้.
Properties
| Properties | Properties | Properties |
|---|---|---|
FileFormat | `str | None` |
เมื่อเกิดขึ้น
- ถูกยกโดย
Document.__init__เมื่อพาร์เซอร์ไม่สามารถระบุไฟล์ว่าเป็นรูปแบบ OneNote ที่รองรับได้.
Properties
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
Properties: from aspose.note import UnsupportedSaveFormatException Properties: AsposeNoteError
ถูกยกเมื่อ Document.Save() ถูกเรียกด้วย SaveFormat หรือคลาส options ที่ไม่ได้รับการทำงานใน v26.3.1. มีเพียง SaveFormat.Pdf ที่ได้รับการทำงาน; รูปแบบอื่นทั้งหมดจะยกข้อยกเว้นนี้.
เมื่อเกิดขึ้น
Document.Save(target, SaveFormat.One)— รูปแบบ OneNote round-trip ถูกประกาศไว้แต่ไม่ได้ทำการใช้งานDocument.Save(target, ...)โดยใช้SaveOptionsซับคลาสที่ไม่ได้PdfSaveOptions
Properties
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}")ดักจับข้อผิดพลาดการโหลดทั้งหมด
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 Noneดักจับข้อผิดพลาดการบันทึกทั้งหมด
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}")ดูเพิ่มเติม
- Properties: ตัวสร้าง (constructor) จะยกข้อยกเว้นการโหลด;
Save()ยกUnsupportedSaveFormatException - LoadOptions: การตั้งค่า
DocumentPasswordทำให้เกิดIncorrectPasswordException - SaveFormat: เฉพาะ
SaveFormat.Pdfถูกนำไปใช้ใน v26.3.1