Skip to main content

codec_pem/
error.rs

1// SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
2//
3// SPDX-License-Identifier: Apache-2.0
4
5use thiserror::Error;
6
7/// Error returned when PEM text armor cannot be parsed or encoded.
8#[derive(Debug, Error, Clone, Copy, PartialEq, Eq)]
9pub enum PemError {
10    /// The input text exceeded the configured maximum size.
11    #[error("pem: input too large")]
12    InputTooLarge,
13    /// The decoded DER body exceeded the configured maximum size.
14    #[error("pem: der body too large")]
15    DerTooLarge,
16    /// The PEM document did not contain a BEGIN boundary.
17    #[error("pem: missing begin boundary")]
18    MissingBegin,
19    /// The PEM document did not contain a matching END boundary.
20    #[error("pem: missing end boundary")]
21    MissingEnd,
22    /// The BEGIN and END labels did not match.
23    #[error("pem: label mismatch")]
24    LabelMismatch,
25    /// The label is not part of the configured allowlist.
26    #[error("pem: unsupported label")]
27    UnsupportedLabel,
28    /// A boundary line was malformed.
29    #[error("pem: invalid boundary")]
30    InvalidBoundary,
31    /// The base64 body was malformed.
32    #[error("pem: invalid base64")]
33    InvalidBase64,
34    /// The body was empty or contained invalid armor data.
35    #[error("pem: invalid body")]
36    InvalidBody,
37    /// The encode options were invalid.
38    #[error("pem: invalid options")]
39    InvalidOptions,
40}