///|
/// Errors raised while parsing X.509 structures.
pub(all) suberror X509Error {
  /// The underlying DER encoding could not be decoded.
  InvalidDer(String)
  /// The PEM wrapper could not be decoded.
  InvalidPem(String)
  /// A required field is missing, has the wrong shape, or is out of range.
  Malformed(String)
} derive(@debug.Debug)

///|
/// Renders the error as a human readable message.
pub fn X509Error::to_string(self : X509Error) -> String {
  match self {
    InvalidDer(message) => "invalid DER: " + message
    InvalidPem(message) => "invalid PEM: " + message
    Malformed(message) => message
  }
}