You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Standardize logging and error handling
- Introduce new types: LoggedResult and LoggedError - Introduce new extension methods to log and add additional msgs - Never exit when logging error messages in Rust (all errors should be handled by using Result and Rust's error propagation) - Remove all usages of anyhow as it doesn't fit Magisk's use cases
This commit is contained in:
@@ -13,4 +13,3 @@ cxx-gen = { workspace = true }
|
||||
[dependencies]
|
||||
base = { path = "../base" }
|
||||
cxx = { workspace = true }
|
||||
anyhow = { workspace = true }
|
||||
|
||||
@@ -38,13 +38,13 @@ impl SepolicyExt for sepolicy {
|
||||
}
|
||||
|
||||
fn load_rule_file(self: Pin<&mut sepolicy>, filename: &[u8]) {
|
||||
fn inner(sepol: Pin<&mut sepolicy>, filename: &[u8]) -> anyhow::Result<()> {
|
||||
fn inner(sepol: Pin<&mut sepolicy>, filename: &[u8]) -> LoggedResult<()> {
|
||||
let filename = str::from_utf8(filename)?;
|
||||
let mut reader = BufReader::new(File::open(filename)?);
|
||||
sepol.load_rules_from_reader(&mut reader);
|
||||
Ok(())
|
||||
}
|
||||
inner(self, filename).log().ok();
|
||||
inner(self, filename).ok();
|
||||
}
|
||||
|
||||
fn load_rules_from_reader<T: BufRead>(mut self: Pin<&mut sepolicy>, reader: &mut T) {
|
||||
|
||||
Reference in New Issue
Block a user