You've already forked AstralRinth
forked from didirus/AstralRinth
Add error handling
This commit is contained in:
@@ -1,21 +1,20 @@
|
||||
use crate::launcher::LauncherError;
|
||||
use lazy_static::lazy_static;
|
||||
use regex::Regex;
|
||||
use std::process::Command;
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum JavaError {
|
||||
#[error("System Error")]
|
||||
SystemError(#[from] std::io::Error),
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref JAVA_VERSION_REGEX: Regex = Regex::new(r#""(.*?)""#).unwrap();
|
||||
}
|
||||
|
||||
pub fn check_java() -> Result<Option<String>, JavaError> {
|
||||
let child = Command::new("/usr/lib/jvm/java-8-openjdk/jre/bin/java")
|
||||
pub fn check_java() -> Result<Option<String>, LauncherError> {
|
||||
let child = Command::new("java")
|
||||
.arg("-version")
|
||||
.output()?;
|
||||
.output()
|
||||
.map_err(|err| LauncherError::ProcessError {
|
||||
inner: err,
|
||||
process: "java".to_string(),
|
||||
})?;
|
||||
|
||||
let output = &*String::from_utf8_lossy(&*child.stderr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user