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
└── UnsupportedSaveFormatExceptionAsposeNoteError
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__amikorload_options.DocumentPasswordnemNone.
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
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|
FileFormat | `str | None` |
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ítvaDocument.Save(target, ...)bármely használatávalSaveOptionsleszármazott osztály, amely nemPdfSaveOptions
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 NoneMinden 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()dobUnsupportedSaveFormatException - LoadOptions: beállítás
DocumentPasswordkiváltIncorrectPasswordException - SaveFormat: csak
SaveFormat.Pdfmeg van valósítva a v26.3.1-ben