MCPcopy Create free account
hub / github.com/PRQL/prql / java_string_with_exception

Function java_string_with_exception

prqlc/bindings/java/src/lib.rs:90–114  ·  view source on GitHub ↗
(result: Result<String, ErrorMessages>, env: &mut JNIEnv)

Source from the content-addressed store, hash-verified

88}
89
90fn java_string_with_exception(result: Result<String, ErrorMessages>, env: &mut JNIEnv) -> jstring {
91 match result {
92 Ok(text) => match env.new_string(text) {
93 Ok(js) => js.into_raw(),
94 Err(e) => {
95 throw_illegal_argument(env, &format!("failed to create java string: {e}"));
96 std::ptr::null_mut()
97 }
98 },
99 Err(err) => {
100 let message = err.to_string();
101 match env.find_class("java/lang/Exception") {
102 Ok(exception) => {
103 if let Err(e) = env.throw_new(exception, message) {
104 eprintln!("Error throwing exception: {e:?}");
105 }
106 }
107 Err(e) => {
108 eprintln!("Error finding java/lang/Exception: {e:?}");
109 }
110 }
111 std::ptr::null_mut()
112 }
113 }
114}

Calls 1

throw_illegal_argumentFunction · 0.85

Tested by

no test coverage detected