Exceptions — Aspose.Note FOSS for Python API Reference
Izņēmumu hierarhija
Visi izņēmumi ir importējami tieši no aspose.note:
from aspose.note import (
AsposeNoteError,
FileCorruptedException,
IncorrectDocumentStructureException,
IncorrectPasswordException,
UnsupportedFileFormatException,
UnsupportedSaveFormatException,
)Mantošanas koks:
Exception
└── AsposeNoteError
├── FileCorruptedException
├── IncorrectDocumentStructureException
├── IncorrectPasswordException
├── UnsupportedFileFormatException
└── UnsupportedSaveFormatExceptionAsposeNoteError
ImageRenderOptions: from aspose.note import AsposeNoteError ImageRenderOptions: Exception
Bāzes klase visiem Aspose.Note FOSS izņēmumiem. Noķeriet šo klasi, lai apstrādātu jebkuru bibliotēkas kļūdu neatkarīgi no konkrētā iemesla.
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
Izsaucas, kad .one failu nevar parsēt, jo tā binārā struktūra ir bojāta vai nepareiza.
Kad izsauc
- Izsauc, ja
Document.__init__kad faila parsētājs sastop neatkārtojamu bināro kļūdu.
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
Izsaucas, kad faila struktūra tiek atpazīta kā a .one fails, bet tas satur nederīgu vai neatbalstītu iekšējo struktūru.
Kad izsauc
- Izraisīts
Document.__init__kad fails iziet pamata formāta pārbaudes, bet tam ir struktūras problēmas, kas neļauj ielādēt.
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
Izraisīts, kad LoadOptions.DocumentPassword ir iestatīts. Šifrēti (ar paroli aizsargāti) dokumenti netiek atbalstīti versijā v26.3.1.
Kad izsauc
- Izraisīts
Document.__init__kadload_options.DocumentPasswordnavNone.
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
Izsauc, ja faila formāts nav atpazīts kā derīgs .one fails. Nodrošina FileFormat atribūtu (virkni) ar noteikto vai mēģināto formāta identifikatoru.
ImageRenderOptions
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|
FileFormat | `str | None` |
Kad izsauc
- Izraisīts
Document.__init__kad parsētājs nevar identificēt failu kā atbalstītu OneNote formātu.
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
Izraisīts, kad Document.Save() tiek izsaukts ar SaveFormat vai opciju klasi, kas nav ieviesta versijā v26.3.1. Tikai SaveFormat.Pdf ir ieviesta; visi pārējie formāti izsauc šo izņēmumu.
Kad izsauc
Document.Save(target, SaveFormat.One)— OneNote round‑trip formāts ir deklarēts, bet nav īstenotsDocument.Save(target, ...)izmantojot jebkuruSaveOptionsapakšklase, kas navPdfSaveOptions
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}")Visu ielādes kļūdu pārtveršana
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 NoneVisu saglabāšanas kļūdu pārtveršana
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}")Skatīt arī
- ImageRenderOptions: konstruktors izsauc ielādes izņēmumus;
Save()izsaucUnsupportedSaveFormatException - LoadOptions: iestatījums
DocumentPasswordizraisaIncorrectPasswordException - SaveFormat: tikai
SaveFormat.Pdfir īstenots versijā v26.3.1