summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2020-06-07 15:16:12 +0100
committerAlex Orlenko <zxteam@protonmail.com>2020-06-07 20:38:19 +0100
commit3d42bc4ca67a1930c49d6cbb4bfa9d60aff8fbbb (patch)
treedfa55adf01abd63efa80edf2a262c2075e074d11 /src/error.rs
parent2eb40deafd13fd0260de6b911d84a677f801897b (diff)
downloadmlua-3d42bc4ca67a1930c49d6cbb4bfa9d60aff8fbbb.zip
Refactor main_state handling
Don't allow to set hook if main_state is not available Remove Lua 5.1 dirty hack
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs
index 4a9a6ef..a06f768 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -43,6 +43,11 @@ pub enum Error {
/// This error can only happen when Lua state was not created by us and does not have the
/// custom allocator attached.
MemoryLimitNotAvailable,
+ /// Main thread is not available.
+ ///
+ /// This error can only happen in Lua5.1/LuaJIT module mode, when module loaded within a coroutine.
+ /// These Lua versions does not have `LUA_RIDX_MAINTHREAD` registry key.
+ MainThreadNotAvailable,
/// A mutable callback has triggered Lua code that has called the same mutable callback again.
///
/// This is an error because a mutable callback can only be borrowed mutably once.
@@ -161,6 +166,9 @@ impl fmt::Display for Error {
Error::MemoryLimitNotAvailable => {
write!(fmt, "setting memory limit is not available")
}
+ Error::MainThreadNotAvailable => {
+ write!(fmt, "main thread is not available in Lua 5.1")
+ }
Error::RecursiveMutCallback => write!(fmt, "mutable callback called recursively"),
Error::CallbackDestructed => write!(
fmt,