-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
39 lines (33 loc) · 1.81 KB
/
errors.go
File metadata and controls
39 lines (33 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2026 Halleluyah Oludele
// Licensed under the MIT License. See LICENSE file in the project root.
package pdftable
import "errors"
// Sentinel errors returned by the public API. Callers can match these with
// errors.Is(); functions that surface a parser-level problem from pdfcpu
// or the content-stream interpreter wrap the underlying error so the cause
// is preserved.
//
// We keep this set small on purpose. The PDF spec has hundreds of failure
// modes — most of them collapse into "the bytes do not look like a PDF",
// "you asked for a page that doesn't exist", or "we don't implement this
// feature yet". Anything more specific belongs in the wrapped error string,
// not as a new sentinel.
var (
// ErrInvalidPDF is returned by Open / OpenBytes / OpenFile when the
// input bytes can't be parsed as a PDF. The underlying pdfcpu error
// is wrapped so callers can still inspect the details with errors.As.
ErrInvalidPDF = errors.New("pdftable: invalid PDF")
// ErrPageOutOfRange is returned by Document.Page when n is < 1 or
// > NumPages(). The PDF page index is 1-based, matching pdfplumber.
ErrPageOutOfRange = errors.New("pdftable: page out of range")
// ErrUnsupported is returned when we hit a PDF feature this library
// does not yet implement (e.g. an exotic CMap, an unsupported XObject
// subtype, vertical writing). The error string names the feature.
ErrUnsupported = errors.New("pdftable: unsupported feature")
// ErrEncrypted is returned when the PDF is encrypted and we can't
// decrypt it with the empty password. Full encryption support is
// out of scope for the initial release — callers that need it can
// pre-decrypt with pdfcpu's api.Decrypt and feed the cleaned bytes
// to OpenBytes.
ErrEncrypted = errors.New("pdftable: encrypted PDF (decryption not yet supported)")
)