From ea718ca29c8bcdae35f06ec10904a5041046ce09 Mon Sep 17 00:00:00 2001 From: Alex Good Date: Sat, 30 Aug 2025 23:13:12 +0100 Subject: [PATCH] More JNI interop cleanup --- rust/src/transaction/delete.rs | 5 ++--- rust/src/transaction/increment.rs | 5 ++--- rust/src/transaction/insert.rs | 13 +++++-------- rust/src/transaction/mark.rs | 7 +++---- rust/src/transaction/set.rs | 9 ++++----- rust/src/transaction/splice.rs | 2 +- rust/src/transaction/splice_text.rs | 2 +- 7 files changed, 18 insertions(+), 25 deletions(-) diff --git a/rust/src/transaction/delete.rs b/rust/src/transaction/delete.rs index 4d2293d..d3235ac 100644 --- a/rust/src/transaction/delete.rs +++ b/rust/src/transaction/delete.rs @@ -25,7 +25,7 @@ impl TransactionOp for DeleteOp { match tx.delete(obj, self.key) { Ok(_) => {} Err(e) => { - env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()).unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()); } } } @@ -64,8 +64,7 @@ pub unsafe extern "C" fn deleteInList<'local>( let idx = match usize::try_from(idx) { Ok(idx) => idx, Err(_) => { - env.throw_new(AUTOMERGE_EXCEPTION, "Index out of bounds") - .unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, "Index out of bounds"); return; } }; diff --git a/rust/src/transaction/increment.rs b/rust/src/transaction/increment.rs index 28a7629..25d85a7 100644 --- a/rust/src/transaction/increment.rs +++ b/rust/src/transaction/increment.rs @@ -29,7 +29,7 @@ impl TransactionOp for IncrementOp { match tx.increment(obj, self.key, self.value) { Ok(_) => {} Err(e) => { - env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()).unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()); } } } @@ -71,8 +71,7 @@ pub unsafe extern "C" fn incrementInList( let idx = match usize::try_from(idx) { Ok(i) => i, Err(_) => { - env.throw_new(AUTOMERGE_EXCEPTION, "index cannot be negative") - .unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, "index cannot be negative"); return; } }; diff --git a/rust/src/transaction/insert.rs b/rust/src/transaction/insert.rs index c904bf1..00e2e3f 100644 --- a/rust/src/transaction/insert.rs +++ b/rust/src/transaction/insert.rs @@ -31,15 +31,14 @@ impl TransactionOp for InsertOp { let idx = match usize::try_from(self.index) { Ok(i) => i, Err(_) => { - env.throw_new(AUTOMERGE_EXCEPTION, "index cannot be negative") - .unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, "index cannot be negative"); return; } }; match tx.insert(obj, idx, self.value) { Ok(_) => {} Err(e) => { - env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()).unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()); } } } @@ -57,15 +56,14 @@ impl TransactionOp for InsertOp { let idx = match usize::try_from(self.index) { Ok(i) => i, Err(_) => { - env.throw_new(AUTOMERGE_EXCEPTION, "index cannot be negative") - .unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, "index cannot be negative"); return JObject::null().into_raw(); } }; let value = match tx.insert_object(obj, idx, self.value) { Ok(v) => v, Err(e) => { - env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()).unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()); return JObject::null().into_raw(); } }; @@ -151,8 +149,7 @@ pub unsafe extern "C" fn insertUintInList( let int = match u64::try_from(value) { Ok(i) => i, Err(_) => { - env.throw_new(AUTOMERGE_EXCEPTION, "uint value must not be negative") - .unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, "uint value must not be negative"); return; } }; diff --git a/rust/src/transaction/mark.rs b/rust/src/transaction/mark.rs index 1751560..c7ac7db 100644 --- a/rust/src/transaction/mark.rs +++ b/rust/src/transaction/mark.rs @@ -37,7 +37,7 @@ impl TransactionOp for MarkOp { Ok(_) => {} Err(e) => { let msg = format!("Error marking: {e}"); - env.throw_new(AUTOMERGE_EXCEPTION, msg).unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, msg); } } } @@ -59,8 +59,7 @@ pub unsafe extern "C" fn markUint( let int = match u64::try_from(value) { Ok(i) => am::ScalarValue::Uint(i), Err(_) => { - env.throw_new(AUTOMERGE_EXCEPTION, "uint value must not be negative") - .unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, "uint value must not be negative"); return; } }; @@ -325,7 +324,7 @@ impl TransactionOp for Unmark { Ok(_) => {} Err(e) => { let msg = format!("Error marking: {e}"); - env.throw_new(AUTOMERGE_EXCEPTION, msg).unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, msg); } } } diff --git a/rust/src/transaction/set.rs b/rust/src/transaction/set.rs index 774a31c..b405eef 100644 --- a/rust/src/transaction/set.rs +++ b/rust/src/transaction/set.rs @@ -28,7 +28,7 @@ impl<'a, V: Into> TransactionOp for SetOp<'a, V> { let key = match self.prop.try_into_prop(env) { Ok(k) => k, Err(e) => { - env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()).unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()); return; } }; @@ -37,7 +37,7 @@ impl<'a, V: Into> TransactionOp for SetOp<'a, V> { match tx.put(obj, key, self.value) { Ok(_) => {} Err(e) => { - env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()).unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()); } } } @@ -453,7 +453,7 @@ impl TransactionOp for SetObjOp { let oid = match tx.put_object(obj, self.key, self.value) { Ok(oid) => oid, Err(e) => { - env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()).unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()); return JObject::null().into_raw(); } }; @@ -501,8 +501,7 @@ pub unsafe extern "C" fn setObjectInList( let idx = match usize::try_from(idx) { Ok(idx) => idx, Err(_) => { - env.throw_new(AUTOMERGE_EXCEPTION, "index must be non-negative") - .unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, "index must be non-negative"); return JObject::null().into_raw(); } }; diff --git a/rust/src/transaction/splice.rs b/rust/src/transaction/splice.rs index f90b0c4..33599c2 100644 --- a/rust/src/transaction/splice.rs +++ b/rust/src/transaction/splice.rs @@ -38,7 +38,7 @@ impl TransactionOp for SpliceOp { match tx.splice(obj, self.index, self.delete, iter) { Ok(_) => {} Err(e) => { - env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()).unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()); } } } diff --git a/rust/src/transaction/splice_text.rs b/rust/src/transaction/splice_text.rs index 63ce769..1ce33b5 100644 --- a/rust/src/transaction/splice_text.rs +++ b/rust/src/transaction/splice_text.rs @@ -31,7 +31,7 @@ impl<'a> TransactionOp for SpliceTextOp<'a> { match tx.splice_text(obj, self.idx as usize, self.delete as isize, &value) { Ok(_) => {} Err(e) => { - env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()).unwrap(); + env.throw_new(AUTOMERGE_EXCEPTION, e.to_string()); } } }