mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Add descriptive error messages for lua registry and oom
This commit is contained in:
parent
30dc027e3e
commit
8e4fc4b65e
5 changed files with 18 additions and 16 deletions
|
@ -146,10 +146,12 @@ where
|
||||||
// a oneshot channel since we move the sender
|
// a oneshot channel since we move the sender
|
||||||
// into our table with the stop function
|
// into our table with the stop function
|
||||||
let (shutdown_tx, mut shutdown_rx) = mpsc::channel::<()>(1);
|
let (shutdown_tx, mut shutdown_rx) = mpsc::channel::<()>(1);
|
||||||
let server_request_callback = lua.create_registry_value(config.handle_request)?;
|
let server_request_callback = lua
|
||||||
|
.create_registry_value(config.handle_request)
|
||||||
|
.expect("Failed to store request handler in registry - out of memory");
|
||||||
let server_websocket_callback = config.handle_web_socket.map(|handler| {
|
let server_websocket_callback = config.handle_web_socket.map(|handler| {
|
||||||
lua.create_registry_value(handler)
|
lua.create_registry_value(handler)
|
||||||
.expect("Failed to store websocket handler")
|
.expect("Failed to store websocket handler in registry - out of memory")
|
||||||
});
|
});
|
||||||
let sched = lua
|
let sched = lua
|
||||||
.app_data_ref::<&Scheduler>()
|
.app_data_ref::<&Scheduler>()
|
||||||
|
|
|
@ -199,7 +199,7 @@ impl<'lua> RequireContext<'lua> {
|
||||||
let multi_key = self
|
let multi_key = self
|
||||||
.lua
|
.lua
|
||||||
.create_registry_value(multi_vec)
|
.create_registry_value(multi_vec)
|
||||||
.expect("Failed to store require result in registry");
|
.expect("Failed to store require result in registry - out of memory");
|
||||||
Ok(multi_key)
|
Ok(multi_key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ impl<'lua> RequireContext<'lua> {
|
||||||
let multi_key = self
|
let multi_key = self
|
||||||
.lua
|
.lua
|
||||||
.create_registry_value(multi_vec)
|
.create_registry_value(multi_vec)
|
||||||
.expect("Failed to store require result in registry");
|
.expect("Failed to store require result in registry - out of memory");
|
||||||
Ok(multi_key)
|
Ok(multi_key)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -66,14 +66,14 @@ where
|
||||||
let stored = match res {
|
let stored = match res {
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
Ok(v) => Ok(Arc::new(
|
Ok(v) => Ok(Arc::new(
|
||||||
self.lua
|
self.lua.create_registry_value(v.into_vec()).expect(
|
||||||
.create_registry_value(v.into_vec())
|
"Failed to store thread results in registry - out of memory",
|
||||||
.expect("Failed to store return values in registry"),
|
),
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
sender
|
sender
|
||||||
.send(stored)
|
.send(stored)
|
||||||
.expect("Failed to broadcast return values of thread");
|
.expect("Failed to broadcast thread results");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ where
|
||||||
let thread = thread.into_lua_thread(self.lua)?;
|
let thread = thread.into_lua_thread(self.lua)?;
|
||||||
let args = LuaMultiValue::new(); // Will be resumed with error, don't need real args
|
let args = LuaMultiValue::new(); // Will be resumed with error, don't need real args
|
||||||
|
|
||||||
let thread = SchedulerThread::new(self.lua, thread, args)?;
|
let thread = SchedulerThread::new(self.lua, thread, args);
|
||||||
let thread_id = thread.id();
|
let thread_id = thread.id();
|
||||||
|
|
||||||
self.state.set_thread_error(thread_id, err);
|
self.state.set_thread_error(thread_id, err);
|
||||||
|
@ -78,7 +78,7 @@ where
|
||||||
let thread = thread.into_lua_thread(self.lua)?;
|
let thread = thread.into_lua_thread(self.lua)?;
|
||||||
let args = args.into_lua_multi(self.lua)?;
|
let args = args.into_lua_multi(self.lua)?;
|
||||||
|
|
||||||
let thread = SchedulerThread::new(self.lua, thread, args)?;
|
let thread = SchedulerThread::new(self.lua, thread, args);
|
||||||
let thread_id = thread.id();
|
let thread_id = thread.id();
|
||||||
|
|
||||||
self.threads
|
self.threads
|
||||||
|
@ -116,7 +116,7 @@ where
|
||||||
let thread = thread.into_lua_thread(self.lua)?;
|
let thread = thread.into_lua_thread(self.lua)?;
|
||||||
let args = args.into_lua_multi(self.lua)?;
|
let args = args.into_lua_multi(self.lua)?;
|
||||||
|
|
||||||
let thread = SchedulerThread::new(self.lua, thread, args)?;
|
let thread = SchedulerThread::new(self.lua, thread, args);
|
||||||
let thread_id = thread.id();
|
let thread_id = thread.id();
|
||||||
|
|
||||||
self.threads
|
self.threads
|
||||||
|
|
|
@ -57,22 +57,22 @@ impl SchedulerThread {
|
||||||
lua: &'lua Lua,
|
lua: &'lua Lua,
|
||||||
thread: LuaThread<'lua>,
|
thread: LuaThread<'lua>,
|
||||||
args: LuaMultiValue<'lua>,
|
args: LuaMultiValue<'lua>,
|
||||||
) -> LuaResult<Self> {
|
) -> Self {
|
||||||
let args_vec = args.into_vec();
|
let args_vec = args.into_vec();
|
||||||
let thread_id = SchedulerThreadId::from(&thread);
|
let thread_id = SchedulerThreadId::from(&thread);
|
||||||
|
|
||||||
let key_thread = lua
|
let key_thread = lua
|
||||||
.create_registry_value(thread)
|
.create_registry_value(thread)
|
||||||
.context("Failed to store value in registry")?;
|
.expect("Failed to store thread in registry - out of memory");
|
||||||
let key_args = lua
|
let key_args = lua
|
||||||
.create_registry_value(args_vec)
|
.create_registry_value(args_vec)
|
||||||
.context("Failed to store value in registry")?;
|
.expect("Failed to store thread args in registry - out of memory");
|
||||||
|
|
||||||
Ok(Self {
|
Self {
|
||||||
thread_id,
|
thread_id,
|
||||||
key_thread,
|
key_thread,
|
||||||
key_args,
|
key_args,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue