Skip to main content

ErrorCode

Enum ErrorCode 

Source
#[non_exhaustive]
pub enum ErrorCode {
Show 129 variants NotPdf, MissingRoot, ReferenceCycle, LimitExceeded, Strict, DataPending, Source, Type, InvalidStructure, UnsetObject, RepairedBase, EncryptedBase, PasswordRequired, WrongPassword, UnsupportedSecurityHandler, UnexpectedEof, Syntax, UnsupportedFilter, Decompress, NestedTransaction, NoTransaction, UnknownPage, DirectPage, UnsupportedVersion, InvalidOpLog, SavedNotRebased, NoPendingSave, MalformedXmp, UnknownSource, OpenActionNotDestination, UnknownOutlineItem, DirectOutlineItem, OutlineNotASibling, OutlineMoveIntoItself, UnknownNamedDestination, NamedDestinationExists, EmptyDestinationName, LinkUriRefused, ViewNotFinite, XmpClaimReadOnly, InvalidXmpPacket, InvalidXmpProperty, NoPagesLeft, InvalidOp, UnknownAnnotation, AnnotationLocked, AnnotationNotEditable, InvalidLabelRanges, Sink, NotRebased, SinkNotEmpty, WouldInvalidateSignatures, RequiresRewrite, InvalidFont, CollectionIndex, UnknownAxis, FontNotEmbeddable, MissingGlyph, GlyphOutOfRange, UnknownFont, SubsetFailed, InvalidAxisValue, WrongDocument, InvalidFeature, InvalidTextRange, InvalidSpans, UnsupportedLayoutOption, FontMismatch, EncodingFull, FontNotShapable, InvalidImage, UnsupportedImage, ImageTooLarge, ImageDataLength, InvalidIccProfile, ColorComponents, InvalidColor, InvalidGeometry, TextOverflow, PageIndexOutOfRange, UnknownDestination, InvalidPageLabels, TagElementNotOpen, TagElementUnclosed, ProfileVersionConflict, MissingTitle, MissingLang, MissingAltText, UntaggedContent, HeadingLevelSkipped, UnnumberedHeadingMisused, InvalidStructureNesting, LinkWithoutStructure, LinkWithoutContents, FontNotEmbedded, GlyphWithoutUnicode, DeviceColorWithoutOutputIntent, EmbeddedFileForbidden, EmbeddedFileWithoutMimeType, FlowContentTooLarge, FlowLayoutUnstable, InvalidDocument, TemplateDataMissing, TemplateDataType, TemplateTooLarge, RenderTooLarge, RenderFailed, RenderBackendUnavailable, ExportFailed, ModelFailed, ModelResultUnexpected, ModelNeedsHost, Cancelled, JobFinished, DocumentChanged, RevisionIndexOutOfRange, BuilderFinished, Disposed, InvalidArgument, SourceBudgetExceeded, UnknownOption, InvalidCommandLine, InvalidPageRange, BinaryOutputToTerminal, UnknownCode, OverwriteRefused, InputUnreadable, OutputUnwritable, PathOutsideRoots,
}
Expand description

Every error code lamina’s Rust crates and its WASM binding raise (the codes only @laminapdf/sdk raises are not here), in codes.json order.

Added in 0.2.0.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

NotPdf

not-pdf: the input does not look like a PDF at all.

§

MissingRoot

missing-root: no document catalog (/Root) was found, even after repair.

§

ReferenceCycle

reference-cycle: a reference chain or the page tree loops back on itself.

§

LimitExceeded

limit-exceeded: a hard Limits value was exceeded.

§

Strict

strict: strict mode refused something the tolerant reader would have repaired.

§

DataPending

data-pending: the ByteSource has not fetched the byte ranges the call needs yet.

§

Source

source: the ByteSource failed to read.

§

Type

type: an object had a different type than the structure requires.

§

InvalidStructure

invalid-structure: an object stream, xref section or filter parameter was malformed.

§

UnsetObject

unset-object: a writer object number was reserved but never given a value.

§

RepairedBase

repaired-base: an incremental update was requested for a document whose xref needed repair.

§

EncryptedBase

encrypted-base: a save of an encrypted document was requested.

§

PasswordRequired

password-required: the document is encrypted with a user password and none was given.

§

WrongPassword

wrong-password: the given password is neither the user nor the owner password.

§

UnsupportedSecurityHandler

unsupported-security-handler: the document uses a security handler Lamina PDF cannot decrypt.

§

UnexpectedEof

unexpected-eof: the input ended before a complete token or object was read.

§

Syntax

syntax: a token or structure did not match the PDF grammar.

§

UnsupportedFilter

unsupported-filter: a stream uses a filter Lamina PDF does not implement.

§

Decompress

decompress: compressed stream data was corrupt.

§

NestedTransaction

nested-transaction: a transaction was started, or undo or redo called, while one is open.

§

NoTransaction

no-transaction: apply, commit or rollback was called without an open transaction.

§

UnknownPage

unknown-page: an op names a page the document does not have.

§

DirectPage

direct-page: the page is a direct dictionary, which ops cannot edit yet.

§

UnsupportedVersion

unsupported-version: an op log has a schema version this reader does not know.

§

InvalidOpLog

invalid-op-log: an op log does not parse: an unknown op or field, a bad value, or not JSON.

§

SavedNotRebased

saved-not-rebased: the document was saved to a sink Lamina PDF cannot read back and waits for rebase.

§

NoPendingSave

no-pending-save: rebase was called without a save waiting for it.

§

MalformedXmp

malformed-xmp: a metadata edit would replace the document’s XMP packet, which can’t be read, losing what it holds.

§

UnknownSource

unknown-source: an op or a call names a source document that was not added to the session.

§

OpenActionNotDestination

open-action-not-destination: an op would replace or remove the document’s open action, which is an action other than a destination.

§

UnknownOutlineItem

unknown-outline-item: an outline op names a bookmark the outline does not have.

§

DirectOutlineItem

direct-outline-item: the bookmark is stored inside another item rather than as an object of its own, so outline ops can’t name it yet.

§

OutlineNotASibling

outline-not-a-sibling: the position names a bookmark that is not a child of the parent the op names.

§

OutlineMoveIntoItself

outline-move-into-itself: a move would put a bookmark inside itself or one of its descendants.

§

UnknownNamedDestination

unknown-named-destination: the op names a destination the file does not define.

§

NamedDestinationExists

named-destination-exists: a rename to a name another destination already has.

§

EmptyDestinationName

empty-destination-name: a destination name is empty.

§

LinkUriRefused

link-uri-refused: a web address that isn’t an absolute http, https or mailto address in plain ASCII.

§

ViewNotFinite

view-not-finite: a destination’s coordinates and zoom must be finite numbers.

§

XmpClaimReadOnly

xmp-claim-read-only: an XMP edit would change the file’s PDF/A or PDF/UA identification, which only conversion or a check may set.

§

InvalidXmpPacket

invalid-xmp-packet: the XMP packet given to replace the document’s doesn’t parse.

§

InvalidXmpProperty

invalid-xmp-property: an XMP property edit names a property, or gives a value, that can’t be written.

§

NoPagesLeft

no-pages-left: a page deletion would leave the document with no pages.

§

InvalidOp

invalid-op: an op’s values are out of range, such as a page count or a page size.

§

UnknownAnnotation

unknown-annotation: the op names an annotation that no page of the document lists.

§

AnnotationLocked

annotation-locked: the annotation’s flags forbid the change: Locked forbids deleting it or changing its properties, LockedContents changing its contents.

§

AnnotationNotEditable

annotation-not-editable: the annotation can’t be edited by the annotation ops: it is a form field’s widget, or a direct dictionary with no object of its own.

§

InvalidLabelRanges

invalid-label-ranges: page label ranges whose first isn’t on the first page, that are out of page order or share a page, or that number from 0.

§

Sink

sink: the sink failed to take the bytes or could not give them back.

§

NotRebased

not-rebased: the output was written, but rebasing the document onto it failed.

§

SinkNotEmpty

sink-not-empty: the sink already held bytes before the save started.

§

WouldInvalidateSignatures

would-invalidate-signatures: the save would break one or more signatures.

§

RequiresRewrite

requires-rewrite: an incremental save was requested but only a full rewrite is safe.

§

InvalidFont

invalid-font: font bytes could not be read as a font.

§

CollectionIndex

collection-index: a font collection member past the end of the collection was asked for.

§

UnknownAxis

unknown-axis: an instance was asked for on a variation axis the font does not have.

§

FontNotEmbeddable

font-not-embeddable: the font’s OS/2 fsType forbids embedding.

§

MissingGlyph

missing-glyph: the font has no glyph for a character of the text.

§

GlyphOutOfRange

glyph-out-of-range: a glyph ID at or past the font’s glyph count was used.

§

UnknownFont

unknown-font: a FontKey was used with a registry that did not hand it out.

§

SubsetFailed

subset-failed: subsetting a font failed.

§

InvalidAxisValue

invalid-axis-value: a variation axis value was NaN or infinite.

§

WrongDocument

wrong-document: finish_fonts was given a document the registry did not reserve its fonts in.

§

InvalidFeature

invalid-feature: an OpenType feature setting did not parse.

§

InvalidTextRange

invalid-text-range: a byte range was out of bounds or not on character boundaries of the text.

§

InvalidSpans

invalid-spans: the styled spans given for a paragraph do not cover its text once, in order.

§

UnsupportedLayoutOption

unsupported-layout-option: a layout option that is not implemented yet was asked for.

§

FontMismatch

font-mismatch: a shaped run was given with a font key for a different font than it was shaped with.

§

EncodingFull

encoding-full: a standard 14 font has no free one-byte code left for another glyph.

§

FontNotShapable

font-not-shapable: a standard 14 font was given to shaping or layout, which need a font program.

§

InvalidImage

invalid-image: image bytes are not a readable image of the format they were given as.

§

UnsupportedImage

unsupported-image: the image uses a feature that PDF or Lamina PDF does not support.

§

ImageTooLarge

image-too-large: the image needs more memory than the builder allows (a decoded PNG over 256 MiB, or raw dimensions whose size overflows).

§

ImageDataLength

image-data-length: raw image samples are not width x height x channels bytes long.

§

InvalidIccProfile

invalid-icc-profile: the bytes are not a usable ICC profile.

§

ColorComponents

color-components: a colour has the wrong number of components for its colour space.

§

InvalidColor

invalid-color: a colour string is not of the form #rgb or #rrggbb.

§

InvalidGeometry

invalid-geometry: a page size, box, /UserUnit, drawing value (coordinate, matrix, line width, dash, miter limit) or image size is not usable.

§

TextOverflow

text-overflow: a text box’s lines don’t all fit its height and its options asked for an error.

§

PageIndexOutOfRange

page-index-out-of-range: a link, outline item or destination names a page index the document doesn’t have.

§

UnknownDestination

unknown-destination: a link or outline item names a destination that was never defined.

§

InvalidPageLabels

invalid-page-labels: page label ranges that don’t start at page 0, don’t increase, start past the last page or number from 0.

§

TagElementNotOpen

tag-element-not-open: a structure element resumed or closed isn’t open.

§

TagElementUnclosed

tag-element-unclosed: structure elements opened across pages were never closed.

§

ProfileVersionConflict

profile-version-conflict: the PDF version asked for is one the profile doesn’t allow (PDF/UA-1, PDF/A-2 and PDF/A-3 are based on PDF 1.7).

§

MissingTitle

missing-title: PDF/UA-1 needs a document title, and the metadata gives none.

§

MissingLang

missing-lang: PDF/UA-1 needs the document’s natural language, and none was set.

§

MissingAltText

missing-alt-text: a Figure or Formula has no alternate text (/Alt or /ActualText), which PDF/UA-1 requires.

§

UntaggedContent

untagged-content: content was drawn outside every structure element and artifact, which PDF/UA-1 forbids.

§

HeadingLevelSkipped

heading-level-skipped: a heading skips a level (the first is not H1, or an H3 follows an H1), which PDF/UA-1 forbids.

§

UnnumberedHeadingMisused

unnumbered-heading-misused: an unnumbered H heading shares its parent with another H, or the document also uses H1-H6, which PDF/UA-1 forbids.

§

InvalidStructureNesting

invalid-structure-nesting: a table or list element sits in a parent its type doesn’t allow (a TD outside a TR, a P directly in a Table).

§

LinkWithoutStructure

link-without-structure: a link annotation has no Link structure element (it was drawn inside an artifact), which PDF/UA-1 forbids.

§

LinkWithoutContents

link-without-contents: a link annotation has no description (/Contents), which PDF/UA-1 requires.

§

FontNotEmbedded

font-not-embedded: a standard 14 font, which is never embedded, was used under a profile that needs every font embedded.

§

GlyphWithoutUnicode

glyph-without-unicode: a glyph was drawn without a Unicode value, which PDF/A-2u and PDF/UA-1 forbid.

§

DeviceColorWithoutOutputIntent

device-color-without-output-intent: a DeviceCMYK colour or image was used, but the PDF/A output intent is sRGB.

§

EmbeddedFileForbidden

embedded-file-forbidden: PDF/A-2 doesn’t allow attached files that aren’t PDF/A themselves.

§

EmbeddedFileWithoutMimeType

embedded-file-without-mime-type: an attached file has no MIME type, which every PDF/A profile requires.

§

FlowContentTooLarge

flow-content-too-large: a line or a figure of a flow is taller than the page’s body, so no page can hold it.

§

FlowLayoutUnstable

flow-layout-unstable: a flow’s contents page kept changing its page numbers after four layouts.

§

InvalidDocument

invalid-document: a laminapdf.document/1 document has an unknown key, a missing one or a value of the wrong kind.

§

TemplateDataMissing

template-data-missing: a template’s $data, $each or $item points to a value the data doesn’t have.

§

TemplateDataType

template-data-type: a template’s placeholder found data of the wrong kind: $each over something that isn’t a list, or text from an object.

§

TemplateTooLarge

template-too-large: a template would fill in more values, or nest deeper, than a document may hold.

§

RenderTooLarge

render-too-large: the requested tile is larger than the render limits allow; nothing was allocated.

§

RenderFailed

render-failed: the render engine could not open the document or draw the page.

§

RenderBackendUnavailable

render-backend-unavailable: the render engine is not available: its library or module could not be loaded.

§

ExportFailed

export-failed: an export’s PNG, JPEG or TIFF encoder failed on a page that was drawn.

§

ModelFailed

model-failed: a layout model, OCR engine or page renderer plugged into an extraction failed; the extraction stops with no partial result.

§

ModelResultUnexpected

model-result-unexpected: a model result was handed to an extraction job that hadn’t asked for it, or was the other model’s result.

§

ModelNeedsHost

model-needs-host: an extraction in one call was given a model whose results only the host can give: a host model, or a plug-in model without a page renderer.

§

Cancelled

cancelled: a CancelToken stopped the work; the job is finished and returned no partial result.

§

JobFinished

job-finished: a job was stepped after it had finished, failed or been cancelled.

§

DocumentChanged

document-changed: the document a job was created for changed (an edit, undo, redo, save or rebase) or a different document was passed to step.

§

RevisionIndexOutOfRange

revision-index-out-of-range: an earlier revision was asked for by an index past the file’s last revision.

§

BuilderFinished

builder-finished: a builder or one of its pages was used after it finished.

§

Disposed

disposed: a document, builder or other handle was used after free(), or after the using block that held it ended.

§

InvalidArgument

invalid-argument: a value passed to a binding does not have the shape its type declares.

§

SourceBudgetExceeded

source-budget-exceeded: a sparse source was given more bytes than its byte budget allows.

§

UnknownOption

unknown-option: an options record passed to a binding has a key Lamina PDF does not know.

§

InvalidCommandLine

invalid-command-line: the command line doesn’t parse: an unknown command or flag, a missing argument, a bad value, or stdin named twice.

§

InvalidPageRange

invalid-page-range: a page range doesn’t fit the grammar, or names a page the document lacks.

§

BinaryOutputToTerminal

binary-output-to-terminal: the command would write a PDF to standard output, and standard output is a terminal.

§

UnknownCode

unknown-code: explain was given a code that isn’t a Lamina PDF error or warning code.

§

OverwriteRefused

overwrite-refused: the output file exists, or the command would modify its input in place, and –force wasn’t given.

§

InputUnreadable

input-unreadable: an input file, standard input or the password file couldn’t be read.

§

OutputUnwritable

output-unwritable: the output couldn’t be written: its folder is missing or read-only, the disk is full, or standard output closed.

§

PathOutsideRoots

path-outside-roots: laminapdf mcp was given a path outside its –root folders, or a link that leads out of them.

Implementations§

Source§

impl ErrorCode

Source

pub const ALL: &'static [Self]

Every variant, in codes.json order.

Added in 0.2.0.

Source

pub const fn from_code(code: &str) -> Option<Self>

The code with this name, if there is one.

Added in 0.2.0.

Source

pub const fn as_str(self) -> &'static str

The kebab-case code.

Added in 0.2.0.

Source

pub const fn kind(self) -> ErrorKind

The kind (ADR 0026 §2).

Added in 0.2.0.

Source

pub const fn summary(self) -> &'static str

One lowercase sentence: what happened.

Added in 0.2.0.

Source

pub const fn hint(self) -> &'static str

The hint (ADR 0026 §5), with its {limit}/{option} parameters unfilled.

Added in 0.2.0.

Source

pub fn docs_url(self) -> String

The code’s explain page (docsUrl, ADR 0026 §6).

Added in 0.2.0.

Trait Implementations§

Source§

impl Clone for ErrorCode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ErrorCode

Source§

impl Debug for ErrorCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ErrorCode

Source§

impl Hash for ErrorCode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ErrorCode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ErrorCode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.