diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-01-31 09:21:56 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-01-31 13:47:24 +0100 |
| commit | a5a6467c9c303bbc28d52c0fb55ed49e164757ad (patch) | |
| tree | 5550d77a1aa9281f63858af99e2726bf10d52cf9 | |
| parent | 7d56bd02a8e057ca2b8bcb87c4b3ec73313cec35 (diff) | |
| download | mullvadvpn-a5a6467c9c303bbc28d52c0fb55ed49e164757ad.tar.xz mullvadvpn-a5a6467c9c303bbc28d52c0fb55ed49e164757ad.zip | |
Add failing string to NoEqual error
| -rw-r--r-- | talpid_openvpn_plugin/src/ffi/parse.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/talpid_openvpn_plugin/src/ffi/parse.rs b/talpid_openvpn_plugin/src/ffi/parse.rs index bcef72570c..cce1204542 100644 --- a/talpid_openvpn_plugin/src/ffi/parse.rs +++ b/talpid_openvpn_plugin/src/ffi/parse.rs @@ -7,8 +7,9 @@ error_chain!{ Null { description("Null pointer") } - NoEqual { + NoEqual(s: String) { description("No equal sign in string") + display("No equal sign in \"{}\"", s) } } foreign_links { @@ -56,7 +57,7 @@ pub unsafe fn env(envptr: *const *const c_char) -> Result<HashMap<String, String for string in string_array(envptr)? { let mut iter = string.splitn(2, "="); let key = iter.next().unwrap(); - let value = iter.next().ok_or(Error::from(ErrorKind::NoEqual))?; + let value = iter.next().ok_or(Error::from(ErrorKind::NoEqual(string.clone())))?; map.insert(key.to_owned(), value.to_owned()); } Ok(map) @@ -127,7 +128,7 @@ mod tests { let test_str = "foobar\0"; let ptr_arr = [test_str as *const _ as *const c_char, ptr::null()]; let result = unsafe { env(&ptr_arr as *const *const c_char) }; - assert_pat!(Err(Error(ErrorKind::NoEqual, _)), result); + assert_pat!(Err(Error(ErrorKind::NoEqual(_), _)), result); } #[test] |
