Exceptions — Aspose.Note FOSS for Python API Reference

استيراد: from aspose.note import AsposeNoteError يرث من: Exception

جميع الاستثناءات يمكن استيرادها مباشرةً من aspose.note:

from aspose.note import (
    AsposeNoteError,
    FileCorruptedException,
    IncorrectDocumentStructureException,
    IncorrectPasswordException,
    UnsupportedFileFormatException,
    UnsupportedSaveFormatException,
)

Aspose.Slides مرجع API مفتوح المصدر لجميع المنصات المدعومة. اختر منصتك لتصفح الفئات والطرق والخصائص.:

Exception
└── AsposeNoteError
    ├── FileCorruptedException
    ├── IncorrectDocumentStructureException
    ├── IncorrectPasswordException
    ├── UnsupportedFileFormatException
    └── UnsupportedSaveFormatException

AsposeNoteError

Example: from aspose.note import AsposeNoteError Example: 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

Example: from aspose.note import FileCorruptedException Example: AsposeNoteError

يُرفع عندما ال .one لا يمكن تحليل الملف لأن هيكله الثنائي معطوب أو مشوه.

مرجع API لجميع الاستثناءات في aspose-note الإصدار 26.3.1 — AsposeNoteError، FileCorruptedException، IncorrectDocumentStructureException، IncorrectPasswordException، UnsupportedFileFormatException، و UnsupportedSaveFormatException.

  • يُرفع بواسطة Document.__init__ عندما يواجه محلل الملف خطأً ثنائياً لا يمكن استرداده.

Example

from aspose.note import Document, FileCorruptedException

try:
    doc = Document("corrupted.one")
except FileCorruptedException as e:
    print(f"File is corrupted: {e}")

IncorrectDocumentStructureException

Example: from aspose.note import IncorrectDocumentStructureException Example: AsposeNoteError

يُرفع عندما يتم التعرف على بنية الملف كـ .one ملف لكنه يحتوي على بنية داخلية غير صالحة أو غير مدعومة.

مرجع API لجميع الاستثناءات في aspose-note الإصدار 26.3.1 — AsposeNoteError، FileCorruptedException، IncorrectDocumentStructureException، IncorrectPasswordException، UnsupportedFileFormatException، و UnsupportedSaveFormatException.

  • يُرفع بواسطة Document.__init__ عندما يجتاز الملف فحوصات التنسيق الأساسية لكنه يواجه مشاكل بنيوية تمنع التحميل.

Example

from aspose.note import Document, IncorrectDocumentStructureException

try:
    doc = Document("unusual.one")
except IncorrectDocumentStructureException as e:
    print(f"Document structure error: {e}")

IncorrectPasswordException

Example: from aspose.note import IncorrectPasswordException Example: AsposeNoteError

يُرفع عندما LoadOptions.DocumentPassword تم التعيين. المستندات المشفرة (المحمية بكلمة مرور) غير مدعومة في v26.3.1.

مرجع API لجميع الاستثناءات في aspose-note الإصدار 26.3.1 — AsposeNoteError، FileCorruptedException، IncorrectDocumentStructureException، IncorrectPasswordException، UnsupportedFileFormatException، و UnsupportedSaveFormatException.

  • تم رفعه بواسطة Document.__init__ عند load_options.DocumentPassword ليس None.

Example

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

Example: from aspose.note import UnsupportedFileFormatException Example: AsposeNoteError

يتم رفعه عندما لا يتم التعرف على تنسيق الملف كتنسيق صالح .one ملف. يكشف عن FileFormat خاصية (سلسلة) تحتوي على معرف التنسيق المكتشف أو المُحاول.

Example

ExampleExampleExample
FileFormat`strNone`

مرجع API لجميع الاستثناءات في aspose-note الإصدار 26.3.1 — AsposeNoteError، FileCorruptedException، IncorrectDocumentStructureException، IncorrectPasswordException، UnsupportedFileFormatException، و UnsupportedSaveFormatException.

  • تم رفعه بواسطة Document.__init__ عند عدم قدرة المحلل على التعرف على الملف كتنسيق OneNote مدعوم.

Example

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

Example: from aspose.note import UnsupportedSaveFormatException Example: AsposeNoteError

يتم رفعه عندما Document.Save() يتم استدعاؤه مع SaveFormat أو فئة خيارات غير مُنفذة في الإصدار v26.3.1. فقط SaveFormat.Pdf مُنفذة؛ جميع الصيغ الأخرى تُثير هذا الاستثناء.

مرجع API لجميع الاستثناءات في aspose-note الإصدار 26.3.1 — AsposeNoteError، FileCorruptedException، IncorrectDocumentStructureException، IncorrectPasswordException، UnsupportedFileFormatException، و UnsupportedSaveFormatException.

  • Document.Save(target, SaveFormat.One) — تم إعلان تنسيق OneNote round-trip لكنه غير مُنفذ
  • Document.Save(target, ...) باستخدام أي SaveOptions فئة فرعية غير PdfSaveOptions

Example

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 UnsupportedFileFormatException يرث من: AsposeNoteError

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

Document.Save(target, SaveFormat.One) — تم إعلان تنسيق OneNote للرحلة المتبادلة لكنه غير مُنفذ

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}")

انظر أيضًا

  • Example: المُنشئ يثير استثناءات التحميل؛; Save() يُثير UnsupportedSaveFormatException
  • LoadOptions: الإعداد DocumentPassword المحفزات IncorrectPasswordException
  • SaveFormat: فقط SaveFormat.Pdf تم تنفيذها في v26.3.1
 العربية