Exceptions

Exceptions — Aspose.Note FOSS for Python API Reference

İstisna Hiyerarşisi

Tüm istisnalar doğrudan şuradan içe aktarılabilir aspose.note:

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

Kalıtım ağacı:

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

AsposeNoteError

Enumerations: from aspose.note import AsposeNoteError Enumerations: Exception

Tüm Aspose.Note FOSS istisnaları için temel sınıf. Belirli nedeni ne olursa olsun, herhangi bir kütüphane hatasını ele almak için bu sınıfı yakalayın.

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

Şu durumda yükseltilir .one dosya, ikili yapısı bozulmuş veya hatalı olduğu için ayrıştırılamaz.

Ne zaman ortaya çıkar

  • Tarafından yükseltilir Document.__init__ dosya ayrıştırıcısı geri döndürülemez bir ikili hatayla karşılaştığında.

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

Dosya yapısı bir … olarak tanındığında yükseltilir .one dosya, ancak geçersiz veya desteklenmeyen bir iç yapıya sahiptir.

Ne zaman ortaya çıkar

  • Tarafından yükseltilir Document.__init__ dosya temel format kontrollerini geçtiğinde ancak yüklemeyi engelleyen yapısal sorunlar olduğunda.

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

Şu durumda ortaya çıkar LoadOptions.DocumentPassword ayarlanmıştır. Şifreli (parola korumalı) belgeler v26.3.1’de desteklenmemektedir.

Ne zaman ortaya çıkar

  • Tarafından ortaya çıkar Document.__init__ şu zaman load_options.DocumentPassword değildir None.

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

Dosya formatı geçerli bir olarak tanınmadığında ortaya çıkar .one dosya. Bir FileFormat algılanan veya denenmiş format tanımlayıcısıyla (bir dize) nitelik.

Enumerations

EnumerationsEnumerationsEnumerations
FileFormat`strNone`

Ne zaman ortaya çıkar

  • Tarafından atılır Document.__init__ ayrıştırıcı dosyayı desteklenen bir OneNote formatı olarak tanıyamadığında.

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

Şu zaman atılır Document.Save() bir … ile çağrıldığında SaveFormat veya v26.3.1’de uygulanmamış seçenek sınıfı. Yalnızca SaveFormat.Pdf uygulanmıştır; diğer tüm formatlar bu istisnaı atar.

Ne zaman ortaya çıkar

  • Document.Save(target, SaveFormat.One) — OneNote round-trip formatu bildirildi ancak uygulanmadı
  • Document.Save(target, ...) herhangi bir … kullanarak SaveOptions uygulamayan alt sınıf 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}")

Tüm Yükleme Hatalarını Yakalama

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

Tüm Kaydetme Hatalarını Yakalama

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

Ayrıca Bakınız

  • Enumerations: yapıcı yükleme istisnaları atar; Save() atır UnsupportedSaveFormatException
  • LoadOptions: ayar DocumentPassword tetikler IncorrectPasswordException
  • SaveFormat: yalnızca SaveFormat.Pdf v26.3.1’de uygulanır
 Türkçe