Exceptions — Aspose.Note FOSS for Python API Reference

Kivételhierarchia

Minden kivétel közvetlenül importálható a aspose.note:

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

Öröklődési fa:

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

AsposeNoteError

ImageRenderOptions: from aspose.note import AsposeNoteError ImageRenderOptions: Exception

Alaposztály minden Aspose.Note FOSS kivételhez. Fogja el ezt az osztályt, hogy bármely könyvtári hibát kezeljen a konkrét ok függetlenül.

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

Kiváltva, amikor a .one A fájlt nem lehet feldolgozni, mert a bináris szerkezete sérült vagy hibás.

Amikor keletkezik

  • Kiváltva Document.__init__ amikor a fájlparancsértelmező helyrehozhatatlan bináris hibát észlel.

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

Kiváltva, amikor a fájl szerkezete úgy van felismerve, mint egy .one fájl, de érvénytelen vagy nem támogatott belső szerkezetet tartalmaz.

Amikor keletkezik

  • Kiváltva Document.__init__ amikor a fájl átmegy az alapvető formátumellenőrzéseken, de olyan szerkezeti problémákat tartalmaz, amelyek megakadályozzák a betöltést.

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

Kiváltva, amikor LoadOptions.DocumentPassword be van állítva. A titkosított (jelszóval védett) dokumentumok nem támogatottak a v26.3.1 verzióban.

Amikor keletkezik

  • Kiváltva Document.__init__ amikor load_options.DocumentPassword nem 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

Kivétel, ha a fájlformátumot nem ismeri fel érvényesnek .one fájl. Megjelenít egy FileFormat attribútumot (karakterlánc) a felismert vagy megkísérelt formátumazonosítóval.

ImageRenderOptions

ImageRenderOptionsImageRenderOptionsImageRenderOptions
FileFormat`strNone`

Amikor keletkezik

  • Kiváltja Document.__init__ ha a parser nem tudja azonosítani a fájlt támogatott OneNote formátumként.

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

Kivétel, amikor Document.Save() hívásra kerül egy SaveFormat vagy opció osztály, amely nincs megvalósítva a v26.3.1-ben. Csak SaveFormat.Pdf van megvalósítva; minden más formátum ezt a kivételt dobja.

Amikor keletkezik

  • Document.Save(target, SaveFormat.One) — A OneNote körkörös formátum deklarálva van, de nincs megvalósítva
  • Document.Save(target, ...) bármely használatával SaveOptions leszármazott osztály, amely nem 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}")

Minden betöltési hiba elkapása

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

Minden mentési hiba elkapása

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

Lásd még

  • ImageRenderOptions: a konstruktor betöltési kivételeket dob; Save() dob UnsupportedSaveFormatException
  • LoadOptions: beállítás DocumentPassword kivált IncorrectPasswordException
  • SaveFormat: csak SaveFormat.Pdf meg van valósítva a v26.3.1-ben
 Magyar