Exceptions — Aspose.Note FOSS for Python API Reference
예외 계층 구조
모든 예외는 직접 import 할 수 있습니다 aspose.note:
from aspose.note import (
AsposeNoteError,
FileCorruptedException,
IncorrectDocumentStructureException,
IncorrectPasswordException,
UnsupportedFileFormatException,
UnsupportedSaveFormatException,
)상속 트리:
Exception
└── AsposeNoteError
├── FileCorruptedException
├── IncorrectDocumentStructureException
├── IncorrectPasswordException
├── UnsupportedFileFormatException
└── UnsupportedSaveFormatExceptionAsposeNoteError
ImageRenderOptions: from aspose.note import AsposeNoteError ImageRenderOptions: Exception
모든 Aspose.Note FOSS 예외의 기본 클래스입니다. 특정 원인에 관계없이 라이브러리 오류를 처리하려면 이 클래스를 잡으세요.
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
다음 경우에 발생합니다 .one 파일의 바이너리 구조가 손상되었거나 잘못되어 파싱할 수 없습니다.
발생 시점
- 다음에 의해 발생합니다
Document.__init__파일 파서가 복구할 수 없는 바이너리 오류를 만나면.
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
파일 구조가 다음과 같이 인식될 때 발생 .one 파일이지만 잘못되었거나 지원되지 않는 내부 구조를 포함하고 있습니다.
발생 시점
- 다음에 의해 발생합니다
Document.__init__파일이 기본 형식 검사를 통과했지만 로딩을 방해하는 구조적 문제가 있을 때.
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
다음 경우에 발생 LoadOptions.DocumentPassword 설정되었습니다. 암호로 보호된(암호화된) 문서는 v26.3.1에서 지원되지 않습니다.
발생 시점
- 발생자
Document.__init__다음 경우에load_options.DocumentPassword은(는) 아닙니다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
파일 형식이 유효한 것으로 인식되지 않을 때 발생 .one 파일. 다음을 노출합니다: FileFormat 속성(문자열)으로 감지되었거나 시도된 형식 식별자를 제공합니다.
ImageRenderOptions
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|
FileFormat | `str | None` |
발생 시점
- 발생자
Document.__init__파서가 파일을 지원되는 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
발생 시 Document.Save() 가 호출될 때 SaveFormat 또는 옵션 클래스가 v26.3.1에 구현되지 않은 경우. Only SaveFormat.Pdf 가 구현되어 있습니다; 다른 모든 형식은 이 예외를 발생시킵니다.
발생 시점
Document.Save(target, SaveFormat.One)— OneNote 라운드트립 형식이 선언되었지만 구현되지 않았습니다Document.Save(target, ...)any 를 사용하여SaveOptions구현되지 않은 subclassPdfSaveOptions
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}")모든 로드 오류 잡기
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모든 저장 오류 잡기
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}")참고
- ImageRenderOptions: 생성자가 로드 예외를 발생시킵니다;
Save()발생시킵니다UnsupportedSaveFormatException - LoadOptions: 설정
DocumentPassword트리거합니다IncorrectPasswordException - SaveFormat: 오직
SaveFormat.Pdf가 v26.3.1에 구현되어 있습니다