Exceptions — Aspose.Note FOSS for Python API Reference
Hierarchia výnimiek
Všetky výnimky je možné importovať priamo z aspose.note:
from aspose.note import (
AsposeNoteError,
FileCorruptedException,
IncorrectDocumentStructureException,
IncorrectPasswordException,
UnsupportedFileFormatException,
UnsupportedSaveFormatException,
)Strom dedičnosti:
Exception
└── AsposeNoteError
├── FileCorruptedException
├── IncorrectDocumentStructureException
├── IncorrectPasswordException
├── UnsupportedFileFormatException
└── UnsupportedSaveFormatExceptionAsposeNoteError
ImageRenderOptions: from aspose.note import AsposeNoteError ImageRenderOptions: Exception
Základná trieda pre všetky Aspose.Note FOSS výnimky. Zachyťte túto triedu, aby ste spracovali akúkoľvek chybu knižnice bez ohľadu na konkrétnu príčinu.
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
Vyvolaná, keď the .one súbor nie je možné analyzovať, pretože jeho binárna štruktúra je poškodená alebo nesprávna.
Keď sa vyvolá
- Vyvolaná
Document.__init__keď parser súboru narazí na neodstrániteľnú binárnu chybu.
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
Vyvolaná, keď je štruktúra súboru rozpoznaná ako .one súbor, ale obsahuje neplatnú alebo nepodporovanú vnútornú štruktúru.
Keď sa vyvolá
- Vyvolaná
Document.__init__keď súbor prejde základnými kontrolami formátu, ale má štrukturálne problémy, ktoré zabraňujú načítaniu.
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
Vyvolaná, keď LoadOptions.DocumentPassword je nastavené. Šifrované (chránené heslom) dokumenty nie sú podporované vo verzii v26.3.1.
Keď sa vyvolá
- Vyvolaná
Document.__init__keďload_options.DocumentPasswordnie jeNone.
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
Vyvolaná, keď formát súboru nie je rozpoznaný ako platný .one súbor. Zverejňuje a FileFormat atribút (reťazec) s detekovaným alebo pokúšaným identifikátorom formátu.
ImageRenderOptions
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|
FileFormat | `str | None` |
Keď sa vyvolá
- Vyvolané v
Document.__init__keď parser nedokáže identifikovať súbor ako podporovaný formát 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
Vyvolané, keď Document.Save() sa volá s SaveFormat alebo triedou možností, ktorá nie je implementovaná vo verzii v26.3.1. Iba SaveFormat.Pdf je implementovaný; všetky ostatné formáty vyvolajú túto výnimku.
Keď sa vyvolá
Document.Save(target, SaveFormat.One)— Formát OneNote round-trip je deklarovaný, ale nie je implementovanýDocument.Save(target, ...)používajúc akýkoľvekSaveOptionspodtriedu, ktorá nie jePdfSaveOptions
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}")Zachytávanie všetkých chýb načítania
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 NoneZachytávanie všetkých chýb ukladania
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}")Pozri tiež
- ImageRenderOptions: konštruktor vyvoláva výnimky pri načítaní;
Save()vyvolávaUnsupportedSaveFormatException - LoadOptions: nastavenie
DocumentPasswordspúšťaIncorrectPasswordException - SaveFormat: iba
SaveFormat.Pdfje implementovaný vo verzii v26.3.1