Exceptions — Aspose.Note FOSS for Python API Reference
Alle Speicherfehler abfangen
Alle Ausnahmen können direkt importiert werden von aspose.note:
from aspose.note import (
AsposeNoteError,
FileCorruptedException,
IncorrectDocumentStructureException,
IncorrectPasswordException,
UnsupportedFileFormatException,
UnsupportedSaveFormatException,
)Vererbungshierarchie:
Exception
└── AsposeNoteError
├── FileCorruptedException
├── IncorrectDocumentStructureException
├── IncorrectPasswordException
├── UnsupportedFileFormatException
└── UnsupportedSaveFormatExceptionAsposeNoteError
Example: from aspose.note import AsposeNoteError Example: Exception
Basisklasse für alle Aspose.Note FOSS-Ausnahmen. Fangen Sie diese Klasse, um jeden Bibliotheksfehler unabhängig von der konkreten Ursache zu behandeln.
from aspose.note import Document, AsposeNoteError
try:
doc = Document("unknown.one")
except AsposeNoteError as e:
print(f"Aspose.Note error: {e}")FileCorruptedException
Example: from aspose.note import FileCorruptedException Example: AsposeNoteError
Ausgelöst, wenn die .one Datei kann nicht geparst werden, weil ihre binäre Struktur beschädigt oder fehlerhaft ist.
Wenn ausgelöst
- Ausgelöst von
Document.__init__wenn der Dateiparser einen nicht wiederherstellbaren binären Fehler entdeckt.
Example
from aspose.note import Document, FileCorruptedException
try:
doc = Document("corrupted.one")
except FileCorruptedException as e:
print(f"File is corrupted: {e}")IncorrectDocumentStructureException
Example: from aspose.note import IncorrectDocumentStructureException Example: AsposeNoteError
Ausgelöst, wenn die Dateistruktur als ein .one Datei, jedoch eine ungültige oder nicht unterstützte interne Struktur enthält.
Wenn ausgelöst
- Ausgelöst von
Document.__init__wenn die Datei die grundlegenden Formatprüfungen besteht, aber strukturelle Probleme hat, die das Laden verhindern.
Example
from aspose.note import Document, IncorrectDocumentStructureException
try:
doc = Document("unusual.one")
except IncorrectDocumentStructureException as e:
print(f"Document structure error: {e}")IncorrectPasswordException
Example: from aspose.note import IncorrectPasswordException Example: AsposeNoteError
Ausgelöst, wenn LoadOptions.DocumentPassword ist gesetzt. Verschlüsselte (passwortgeschützte) Dokumente werden in v26.3.1 nicht unterstützt.
Wenn ausgelöst
- Ausgelöst von
Document.__init__wennload_options.DocumentPasswordist nichtNone.
Example
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
Example: from aspose.note import UnsupportedFileFormatException Example: AsposeNoteError
Ausgelöst, wenn das Dateiformat nicht als gültiges erkannt wird .one Datei. Stellt ein FileFormat Attribut (ein String) mit dem erkannten oder versuchten Formatbezeichner.
Example
| Example | Example | Example |
|---|---|---|
FileFormat | `str | None` |
Wenn ausgelöst
- Ausgelöst von
Document.__init__wenn der Parser die Datei nicht als unterstütztes OneNote‑Format identifizieren kann.
Example
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
Example: from aspose.note import UnsupportedSaveFormatException Example: AsposeNoteError
Ausgelöst, wenn Document.Save() aufgerufen wird mit einem SaveFormat oder Optionsklasse, die in v26.3.1 nicht implementiert ist. Nur SaveFormat.Pdf ist implementiert; alle anderen Formate lösen diese Ausnahme aus.
Wenn ausgelöst
Document.Save(target, SaveFormat.One)— OneNote Round-Trip-Format ist deklariert, aber nicht implementiertDocument.Save(target, ...)unter Verwendung von beliebigenSaveOptionsUnterklasse, die nichtPdfSaveOptions
Example
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}")Aspose.Slides FOSS API-Referenz für alle unterstützten Plattformen. Wählen Sie Ihre Plattform, um Klassen, Methoden und Eigenschaften zu durchsuchen.
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 NoneAlle Speicherfehler abfangen
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}")Siehe auch
- Example: Konstruktor wirft Ladeausnahmen;
Save()wirftUnsupportedSaveFormatException - LoadOptions: Einstellung
DocumentPasswordlöst ausIncorrectPasswordException - SaveFormat: nur
SaveFormat.Pdfist implementiert in v26.3.1