Skip to content

Commit 51ae9cb

Browse files
committed
fix lints
1 parent b5fc8c7 commit 51ae9cb

File tree

6 files changed

+20
-34
lines changed

6 files changed

+20
-34
lines changed

src/common.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{BrowserOptions, Error, ErrorKind, Result};
1+
use super::{BrowserOptions, Error, Result};
22
use log::debug;
33
use std::process::{Command, Stdio};
44

@@ -80,10 +80,7 @@ pub(crate) fn run_command(
8080
if status.success() {
8181
Ok(())
8282
} else {
83-
Err(Error::new(
84-
ErrorKind::Other,
85-
"command present but exited unsuccessfully",
86-
))
83+
Err(Error::other("command present but exited unsuccessfully"))
8784
}
8885
})
8986
}

src/ios.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::ffi::c_void;
33
use objc2::{class, msg_send, rc::Retained, Encode, Encoding, MainThreadMarker};
44
use objc2_foundation::{NSDictionary, NSObject, NSString, NSURL};
55

6-
use crate::{Browser, BrowserOptions, Error, ErrorKind, Result, TargetType};
6+
use crate::{Browser, BrowserOptions, Error, Result, TargetType};
77

88
/// Returns `UIApplication`
99
#[allow(non_snake_case)]
@@ -50,24 +50,20 @@ pub(super) fn open_browser_internal(
5050
return Ok(());
5151
}
5252

53-
let mtm = MainThreadMarker::new().ok_or(Error::new(
54-
ErrorKind::Other,
53+
let mtm = MainThreadMarker::new().ok_or(Error::other(
5554
"UIApplication must be retrieved on the main thread",
5655
))?;
5756

58-
let app = sharedApplication(mtm).ok_or(Error::new(
59-
ErrorKind::Other,
57+
let app = sharedApplication(mtm).ok_or(Error::other(
6058
"UIApplication is NULL, perhaps UIApplicationMain has not been executed?",
6159
))?;
6260

6361
// Create ns string class from our string
6462
let url_string = NSString::from_str(url);
6563
// Create NSURL object with given string
6664
#[allow(unused_unsafe)] // fix lint for now, eventually remove unsafe
67-
let url_object = unsafe { NSURL::URLWithString(&url_string) }.ok_or(Error::new(
68-
ErrorKind::Other,
69-
"Failed creating NSURL; is the URL valid?",
70-
))?;
65+
let url_object = unsafe { NSURL::URLWithString(&url_string) }
66+
.ok_or(Error::other("Failed creating NSURL; is the URL valid?"))?;
7167
// empty options dictionary
7268
let options = NSDictionary::new();
7369

src/macos.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ pub(super) fn open_browser_internal(
4848
))
4949
}
5050
}
51-
.ok_or_else(|| Error::new(ErrorKind::Other, "failed to create CFURL"))?;
51+
.ok_or_else(|| Error::other("failed to create CFURL"))?;
5252

53-
let cf_url = create_cf_url(target.as_ref())
54-
.ok_or_else(|| Error::new(ErrorKind::Other, "failed to create CFURL"))?;
53+
let cf_url =
54+
create_cf_url(target.as_ref()).ok_or_else(|| Error::other("failed to create CFURL"))?;
5555

5656
let urls_v = [cf_url];
5757
let urls_arr = CFArray::<CFURL>::from_CFTypes(&urls_v);
@@ -78,10 +78,7 @@ pub(super) fn open_browser_internal(
7878
Err(Error::new(ErrorKind::NotFound, "browser not found"))
7979
}
8080
} else {
81-
Err(Error::new(
82-
ErrorKind::Other,
83-
"unable to convert app url to path",
84-
))
81+
Err(Error::other("unable to convert app url to path"))
8582
};
8683
}
8784

src/unix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ fn try_xdg(options: &BrowserOptions, url: &str) -> Result<()> {
313313
}
314314

315315
if config_found {
316-
Err(Error::new(ErrorKind::Other, "xdg-open failed"))
316+
Err(Error::other("xdg-open failed"))
317317
} else {
318318
Err(Error::new(ErrorKind::NotFound, "no valid xdg config found"))
319319
}
@@ -764,7 +764,7 @@ mod wsl {
764764

765765
/// Gets the WSL distro name
766766
fn get_wsl_distro_name(wc: &WindowsConfig) -> Result<String> {
767-
let err_fn = || Error::new(ErrorKind::Other, "unable to determine wsl distro name");
767+
let err_fn = || Error::other("unable to determine wsl distro name");
768768

769769
// mostly we should be able to get it from the WSL_DISTRO_NAME env var
770770
if let Ok(wsl_hostname) = std::env::var("WSL_DISTRO_NAME") {

src/wasm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{Browser, BrowserOptions, Error, ErrorKind, Result, TargetType};
1+
use crate::{Browser, BrowserOptions, Error, Result, TargetType};
22

33
/// Deal with opening a URL in wasm. This implementation ignores the browser attribute
44
/// and always opens URLs in the same browser where wasm vm is running.
@@ -15,7 +15,7 @@ pub(super) fn open_browser_internal(
1515
if web_sys::window().is_some() {
1616
return Ok(());
1717
} else {
18-
return Err(Error::new(ErrorKind::Other, "no browser window available"));
18+
return Err(Error::other("no browser window available"));
1919
}
2020
}
2121

@@ -26,15 +26,15 @@ pub(super) fn open_browser_internal(
2626
Some(_) => Ok(()),
2727
None => {
2828
wasm_console_log(POPUP_ERR_MSG, options);
29-
Err(Error::new(ErrorKind::Other, POPUP_ERR_MSG))
29+
Err(Error::other(POPUP_ERR_MSG))
3030
}
3131
},
3232
Err(_) => {
3333
wasm_console_log("window error while opening url", options);
34-
Err(Error::new(ErrorKind::Other, "error opening url"))
34+
Err(Error::other("error opening url"))
3535
}
3636
},
37-
None => Err(Error::new(ErrorKind::Other, "no browser window available")),
37+
None => Err(Error::other("no browser window available")),
3838
}
3939
}
4040

src/windows.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,14 @@ pub(super) fn open_browser_internal(
5151
&mut line_len,
5252
) != 0
5353
{
54-
return Err(Error::new(
55-
ErrorKind::Other,
56-
"failed to get default browser",
57-
));
54+
return Err(Error::other("failed to get default browser"));
5855
}
5956

6057
use std::os::windows::ffi::OsStringExt;
6158
std::ffi::OsString::from_wide(&cmdline_u16[..(line_len - 1) as usize])
6259
.into_string()
6360
.map_err(|_err| {
64-
Error::new(
65-
ErrorKind::Other,
61+
Error::other(
6662
"The default web browser command contains invalid unicode characters",
6763
)
6864
})?

0 commit comments

Comments
 (0)