mirror of
https://github.com/lune-org/lune.git
synced 2025-04-16 18:03:57 +01:00
Throw syntax error instead of runtime error
This commit is contained in:
parent
9e25ab51b9
commit
39870f6b87
1 changed files with 24 additions and 18 deletions
|
@ -29,13 +29,15 @@ where
|
||||||
// 1. Try to require the exact path
|
// 1. Try to require the exact path
|
||||||
match require_inner(lua, ctx, &abs_path, &rel_path).await {
|
match require_inner(lua, ctx, &abs_path, &rel_path).await {
|
||||||
Ok(res) => return Ok(res),
|
Ok(res) => return Ok(res),
|
||||||
Err(LuaError::SyntaxError {
|
Err(error) => {
|
||||||
message,
|
if let LuaError::SyntaxError {
|
||||||
incomplete_input: _,
|
message: _,
|
||||||
}) => {
|
incomplete_input: _,
|
||||||
return Err(LuaError::runtime(message));
|
} = error
|
||||||
|
{
|
||||||
|
return Err(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(_) => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Try to require the path with an added "luau" extension
|
// 2. Try to require the path with an added "luau" extension
|
||||||
|
@ -50,13 +52,15 @@ where
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(res) => return Ok(res),
|
Ok(res) => return Ok(res),
|
||||||
Err(LuaError::SyntaxError {
|
Err(error) => {
|
||||||
message,
|
if let LuaError::SyntaxError {
|
||||||
incomplete_input: _,
|
message: _,
|
||||||
}) => {
|
incomplete_input: _,
|
||||||
return Err(LuaError::runtime(message));
|
} = error
|
||||||
|
{
|
||||||
|
return Err(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(_) => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,13 +81,15 @@ where
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(res) => return Ok(res),
|
Ok(res) => return Ok(res),
|
||||||
Err(LuaError::SyntaxError {
|
Err(error) => {
|
||||||
message,
|
if let LuaError::SyntaxError {
|
||||||
incomplete_input: _,
|
message: _,
|
||||||
}) => {
|
incomplete_input: _,
|
||||||
return Err(LuaError::runtime(message));
|
} = error
|
||||||
|
{
|
||||||
|
return Err(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(_) => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue