c2pa_text_binding/
error.rs1use std::fmt;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum Error {
8 ContentTooShort,
11 GenerationFailed(String),
13 MatchFailed(String),
15 Coding(String),
17 TagMismatch,
20 WatermarkUnrecoverable,
22 InvalidInput(String),
24}
25
26impl fmt::Display for Error {
27 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28 match self {
29 Self::ContentTooShort => {
30 write!(f, "text content too short for this soft-binding algorithm")
31 }
32 Self::GenerationFailed(s) => write!(f, "fingerprint generation failed: {s}"),
33 Self::MatchFailed(s) => write!(f, "fingerprint match failed: {s}"),
34 Self::Coding(s) => write!(f, "reed-solomon coding failed: {s}"),
35 Self::TagMismatch => write!(
36 f,
37 "watermark content-binding tag did not verify (transferred or modified content)"
38 ),
39 Self::WatermarkUnrecoverable => {
40 write!(
41 f,
42 "watermark could not be recovered from remaining positions"
43 )
44 }
45 Self::InvalidInput(s) => write!(f, "invalid input: {s}"),
46 }
47 }
48}
49
50impl std::error::Error for Error {}