Git · dadoum.zone
Repositories
Help
Report an Issue
apple-crates
Code
Commits
Branches
Tags
Search
Tree:
a74924e
Branches
Tags
main
apple-crates
apple-codesign-quick
src
error.rs
Refactor and unify a lot of things for another project and implement airdrop support
Dadoum
commited
a74924e
at 2026-10-25 22:15:58
error.rs
Blame
History
Raw
use std::fmt::Display; use std::io; use std::path::{Path, PathBuf}; use thiserror::Error; #[derive(Debug, Error)] pub enum CodeSignError { #[error("I/O error on {path}: {source}")] Io { path: PathBuf, source: io::Error }, #[error("Invalid property list: {0}")] Plist(#[from] plist::Error), #[error("The bundle has no Info.plist: {0}")] MissingInfoPlist(PathBuf), #[error("Info.plist has no {0} string")] MissingInfoString(&'static str), #[error("Invalid path in the bundle: {0}")] InvalidBundlePath(PathBuf), #[error("Invalid argument: {0}")] Argument(String), #[error("Invalid Mach-O {path}: {message}")] MachO { path: PathBuf, message: String }, #[error( "Cannot add a code signature to {path}: there is no header padding left for LC_CODE_SIGNATURE ({signature_len} byte signature)" )] NeedsCodeSignatureAllocation { path: PathBuf, signature_len: usize }, #[error("Unsupported entitlement value: {0}")] UnsupportedEntitlement(String), #[error("CMS signing failed: {0}")] Cms(String), #[error("Invalid provisioning profile: {0}")] ProvisioningProfile(String), #[error("The CMS signature is {actual} bytes, exceeding the {reserved} byte reservation")] SignatureTooLarge { actual: usize, reserved: usize }, } impl CodeSignError { /// For `map_err`: an I/O error on `path`. pub(crate) fn io(path: &Path) -> impl FnOnce(io::Error) -> CodeSignError + '_ { move |source| CodeSignError::Io { path: path.to_path_buf(), source, } } pub(crate) fn macho(path: &Path, message: impl Into<String>) -> Self { CodeSignError::MachO { path: path.to_path_buf(), message: message.into(), } } pub(crate) fn cms(error: impl Display) -> Self { CodeSignError::Cms(error.to_string()) } pub(crate) fn provisioning_profile(error: impl Display) -> Self { CodeSignError::ProvisioningProfile(error.to_string()) } } pub type Result<T> = std::result::Result<T, CodeSignError>;