mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Decreased the nesting for the error handling
This commit is contained in:
parent
0000814eaf
commit
578de55d98
1 changed files with 9 additions and 6 deletions
|
|
@ -113,12 +113,15 @@ fn open(lua: &Lua) -> mlua::Result<Function> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = open_opts.open(&*url).await;
|
let result = open_opts.open(&*url).await;
|
||||||
match result {
|
let yazi_file = yazi_fs::File::from(url.clone()).await;
|
||||||
Ok(_) => match File::cast(&lua, yazi_fs::File::from_dummy(url.clone(), None)) {
|
|
||||||
Ok(f) => (f, Value::Nil).into_lua_multi(&lua),
|
match (result, yazi_file) {
|
||||||
Err(e) => (Value::Nil, e).into_lua_multi(&lua),
|
(Ok(_), Ok(f)) => match File::cast(&lua, f) {
|
||||||
},
|
Ok(file) => (file, Value::Nil).into_lua_multi(&lua),
|
||||||
Err(e) => (Value::Nil, Error::Io(e)).into_lua_multi(&lua),
|
Err(e) => (Value::Nil, e).into_lua_multi(&lua)
|
||||||
|
}
|
||||||
|
(Err(e), _) => (Value::Nil, Error::Io(e)).into_lua_multi(&lua),
|
||||||
|
(_, Err(e)) => (Value::Nil, e).into_lua_multi(&lua)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue