Improve error handling

This commit is contained in:
nab138
2026-01-02 23:17:29 -05:00
parent 8b96b49d2f
commit c1fb156908
4 changed files with 20 additions and 20 deletions

2
Cargo.lock generated
View File

@@ -977,7 +977,7 @@ checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130"
[[package]] [[package]]
name = "isideload" name = "isideload"
version = "0.1.23" version = "0.1.24"
dependencies = [ dependencies = [
"hex", "hex",
"idevice", "idevice",

View File

@@ -3,7 +3,7 @@ name = "isideload"
description = "Sideload iOS/iPadOS applications" description = "Sideload iOS/iPadOS applications"
license = "MPL-2.0" license = "MPL-2.0"
authors = ["Nicholas Sharp <nab@nabdev.me>"] authors = ["Nicholas Sharp <nab@nabdev.me>"]
version = "0.1.23" version = "0.1.24"
edition = "2024" edition = "2024"
repository = "https://github.com/nab138/isideload" repository = "https://github.com/nab138/isideload"
documentation = "https://docs.rs/isideload" documentation = "https://docs.rs/isideload"

View File

@@ -1,7 +1,8 @@
// This file was made using https://github.com/Dadoum/Sideloader as a reference for the apple private endpoints // This file was made using https://github.com/Dadoum/Sideloader as a reference for the apple private endpoints
use crate::{Error, obf}; use crate::{Error, obf};
use icloud_auth::{AppleAccount, Error as ICloudError}; use icloud_auth::AppleAccount;
use idevice::pretty_print_dictionary;
use plist::{Date, Dictionary, Value}; use plist::{Date, Dictionary, Value};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::sync::Arc; use std::sync::Arc;
@@ -52,13 +53,7 @@ impl DeveloperSession {
.account .account
.send_request(url, Some(request)) .send_request(url, Some(request))
.await .await
.map_err(|e| { .map_err(|e| Error::ICloudError(e))?;
if let ICloudError::AuthSrpWithMessage(code, message) = e {
Error::DeveloperSession(code, format!("Developer request failed: {}", message))
} else {
Error::Generic("Failed to send developer request".to_string())
}
})?;
let status_code = response let status_code = response
.get("resultCode") .get("resultCode")
@@ -256,16 +251,19 @@ impl DeveloperSession {
.and_then(|v| v.as_string()) .and_then(|v| v.as_string())
.ok_or(Error::Parse("serialNumber".to_string()))? .ok_or(Error::Parse("serialNumber".to_string()))?
.to_string(); .to_string();
let machine_name = dict let machine_name = match dict.get("machineName").and_then(|v| v.as_string()) {
.get("machineName") Some(name) => name.to_string(),
.and_then(|v| v.as_string()) None => "".to_string(),
.unwrap_or("") };
.to_string();
let machine_id = dict let machine_id = match dict.get("machineId").and_then(|v| v.as_string()) {
.get("machineId") Some(id) => Ok(id.to_string()),
.and_then(|v| v.as_string()) None => Err(Error::Parse(format!(
.ok_or(Error::Parse("machineId".to_string()))? "machineId {:?}",
.to_string(); pretty_print_dictionary(dict)
))),
}?;
let cert_content = dict let cert_content = dict
.get("certContent") .get("certContent")
.and_then(|v| v.as_data()) .and_then(|v| v.as_data())

View File

@@ -34,6 +34,8 @@ pub enum Error {
IdeviceError(#[from] IdeviceError), IdeviceError(#[from] IdeviceError),
#[error(transparent)] #[error(transparent)]
ZSignError(#[from] ZSignError), ZSignError(#[from] ZSignError),
#[error(transparent)]
ICloudError(#[from] icloud_auth::Error),
} }
pub trait SideloadLogger: Send + Sync { pub trait SideloadLogger: Send + Sync {