mirror of
https://github.com/nushell/nushell.git
synced 2024-12-25 08:29:07 +01:00
Better error messages, remove last (?) unwrap
This commit is contained in:
parent
c5b8abbcd3
commit
aaacf4c336
@ -75,7 +75,7 @@ impl DirectorySpecificEnvironment {
|
||||
k.clone(),
|
||||
v.to_str()
|
||||
.ok_or_else(|| {
|
||||
Error::new(ErrorKind::Other, "Filepath is not valid unicode")
|
||||
Error::new(ErrorKind::Other, format!("{:?} is not valid unicode", v))
|
||||
})?
|
||||
.to_string(),
|
||||
);
|
||||
@ -118,7 +118,17 @@ impl DirectorySpecificEnvironment {
|
||||
|
||||
let mut keys_in_current_nufile = vec![];
|
||||
for (k, v) in vars_in_current_file {
|
||||
vars_to_add.insert(k.clone(), v.as_str().unwrap().to_string()); //This is used to add variables to the environment
|
||||
vars_to_add.insert(
|
||||
k.clone(),
|
||||
v.as_str()
|
||||
.ok_or_else(|| {
|
||||
Error::new(
|
||||
ErrorKind::InvalidData,
|
||||
format!("Could not read environment variable: {}", v),
|
||||
)
|
||||
})?
|
||||
.to_string(),
|
||||
); //This is used to add variables to the environment
|
||||
keys_in_current_nufile.push(k.clone()); //this is used to keep track of which directory added which variables
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user