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
ImageRenderOptions: from aspose.note import AsposeNoteError ImageRenderOptions: Exception
کلاس پایه برای تمام استثناهای Aspose.Note FOSS. این کلاس را بگیرید تا هر خطای کتابخانهای را صرفنظر از دلیل خاص آن مدیریت کنید.
from aspose.note import Document, AsposeNoteError
try:
doc = Document("unknown.one")
except AsposeNoteError as e:
print(f"Aspose.Note error: {e}")FileCorruptedException
ImageRenderOptions: from aspose.note import FileCorruptedException ImageRenderOptions: AsposeNoteError
زمانی که .one فایل نمیتواند تجزیه شود زیرا ساختار باینری آن خراب یا نامعتبر است.
زمانی که رخ میدهد
- ایجاد شده توسط
Document.__init__زمانی که تجزیهکنندهٔ فایل با خطای باینری غیرقابل بازیابی مواجه میشود.
ImageRenderOptions
from aspose.note import Document, FileCorruptedException
try:
doc = Document("corrupted.one")
except FileCorruptedException as e:
print(f"File is corrupted: {e}")IncorrectDocumentStructureException
ImageRenderOptions: from aspose.note import IncorrectDocumentStructureException ImageRenderOptions: AsposeNoteError
زمانی که ساختار فایل به عنوان یک .one فایل شناسایی میشود اما شامل ساختار داخلی نامعتبر یا پشتیبانینشده است.
زمانی که رخ میدهد
- ایجاد شده توسط
Document.__init__زمانی که فایل بررسیهای پایهٔ قالب را پاس میکند اما مشکلات ساختاری دارد که مانع بارگذاری میشود.
ImageRenderOptions
from aspose.note import Document, IncorrectDocumentStructureException
try:
doc = Document("unusual.one")
except IncorrectDocumentStructureException as e:
print(f"Document structure error: {e}")IncorrectPasswordException
ImageRenderOptions: from aspose.note import IncorrectPasswordException ImageRenderOptions: AsposeNoteError
در زمان بروز LoadOptions.DocumentPassword تنظیم شده است. اسناد رمزگذاریشده (محافظتشده با رمز عبور) در نسخهٔ v26.3.1 پشتیبانی نمیشوند.
زمانی که رخ میدهد
- ایجاد شده توسط
Document.__init__زمانی کهload_options.DocumentPasswordنیستNone.
ImageRenderOptions
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
ImageRenderOptions: from aspose.note import UnsupportedFileFormatException ImageRenderOptions: AsposeNoteError
در زمان بروز که قالب فایل به عنوان یک قالب معتبر شناسایی نمیشود .one فایل. یک FileFormat ویژگی (یک رشته) حاوی شناسهٔ قالب شناساییشده یا مورد تلاش.
ImageRenderOptions
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|
FileFormat | `str | None` |
زمانی که رخ میدهد
- ایجاد شده توسط
Document.__init__زمانی که تجزیهکننده نتواند فایل را بهعنوان یک فرمت OneNote پشتیبانیشده شناسایی کند.
ImageRenderOptions
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
ImageRenderOptions: from aspose.note import UnsupportedSaveFormatException ImageRenderOptions: AsposeNoteError
ایجاد شده زمانی که Document.Save() با یک SaveFormat یا کلاس گزینهها که در نسخه v26.3.1 پیادهسازی نشده است. فقط SaveFormat.Pdf پیادهسازی شده است؛ تمام فرمتهای دیگر این استثنا را پرتاب میکنند.
زمانی که رخ میدهد
Document.Save(target, SaveFormat.One)— فرمت round-trip OneNote اعلام شده است اما پیادهسازی نشده استDocument.Save(target, ...)با استفاده از هرSaveOptionsزیرکلاس که نیستPdfSaveOptions
ImageRenderOptions
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}")همچنین ببینید
- ImageRenderOptions:سازنده استثنای بارگذاری را پرتاب میکند؛;
Save()پر میکندUnsupportedSaveFormatException - LoadOptions: تنظیم
DocumentPasswordراهاندازی میکندIncorrectPasswordException - SaveFormat: فقط
SaveFormat.Pdfدر v26.3.1 پیادهسازی شده است