Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Mark what needs to be done for async errors

Change-Id: I4b9744d1a67d73e8dc9b20513b0a5ab0b981c46f
  • Loading branch information...
commit 49624ce990f6e9412f60a4bf16c511f361caec53 1 parent d7d8fc7
@creationix creationix authored
View
22 errors.markdown
@@ -0,0 +1,22 @@
+
+# Classes of errors
+
+ - Sync argument errors. These should "throw" and many do because that's how `luaL_check*` works.
+ - Errors while async. These happened while trying to do an async action. They should either be handed to the callback or emitted as error.
+ - Error while executing async callbacks. If an error handler has a bug, there isn't much we can do. Either "throw" or send as "error" event if possible.
+
+# Error handling
+
+ - async errors are always handed to lua somewhere with the exception of "error" events that aren't listened for
+ - uncaught "error" events and sync errors will crash the process and should always show a stack trace
+
+# Current places where async errors happen
+
+I know errno and path, this is a fs error
+
+ luv_io_error(L, req->errorno, NULL, NULL, req->path);
+
+I only know it was the last error (`after shutdown`, `after_write`, `on_connection`)
+
+ luv_io_error(L, uv_last_error(uv_default_loop()).code, NULL, NULL, NULL);
+
View
1  src/luv_fs.c
@@ -74,6 +74,7 @@ void luv_after_fs(uv_fs_t* req) {
int argc = 0;
if (req->result == -1) {
+ // FIXME: PROPER ERROR HANDLER
luv_io_error(L, req->errorno, NULL, NULL, req->path);
} else {
lua_pushnil(L);
View
1  src/luv_fs_watcher.c
@@ -12,6 +12,7 @@ void luv_on_fs_event(uv_fs_event_t* handle, const char* filename, int events, in
int before = lua_gettop(L);
lua_rawgeti(L, LUA_REGISTRYINDEX, ref->r);
+ // FIXME: PROPER ERROR HANDLER
lua_pushinteger(L, status);
switch (events) {
View
1  src/luv_handle.c
@@ -46,6 +46,7 @@ void luv_after_connect(uv_connect_t* req, int status) {
int before = lua_gettop(L);
lua_rawgeti(L, LUA_REGISTRYINDEX, ref->r);
+ // FIXME: PROPER ERROR HANDLER
lua_pushinteger(L, status);
luv_emit_event(L, "complete", 1);
View
3  src/luv_stream.c
@@ -9,6 +9,7 @@ void luv_on_connection(uv_stream_t* handle, int status) {
lua_State *L = ref->L;
int before = lua_gettop(L);
lua_rawgeti(L, LUA_REGISTRYINDEX, ref->r);
+ // FIXME: PROPER ERROR HANDLER
if (status == -1) {
luv_io_error(L, uv_last_error(uv_default_loop()).code, NULL, NULL, NULL);
luv_emit_event(L, "connection", 1);
@@ -57,6 +58,7 @@ void luv_after_shutdown(uv_shutdown_t* req, int status) {
lua_rawgeti(L, LUA_REGISTRYINDEX, ref->r);
luaL_unref(L, LUA_REGISTRYINDEX, ref->r);
+ // FIXME: PROPER ERROR HANDLER
if (lua_isfunction(L, -1)) {
if (status == -1) {
luv_io_error(L, uv_last_error(uv_default_loop()).code, NULL, NULL, NULL);
@@ -80,6 +82,7 @@ void luv_after_write(uv_write_t* req, int status) {
int before = lua_gettop(L);
lua_rawgeti(L, LUA_REGISTRYINDEX, ref->r);
luaL_unref(L, LUA_REGISTRYINDEX, ref->r);
+ // FIXME: PROPER ERROR HANDLER
if (lua_isfunction(L, -1)) {
if (status == -1) {
luv_io_error(L, uv_last_error(uv_default_loop()).code, NULL, NULL, NULL);
View
1  src/luv_timer.c
@@ -36,6 +36,7 @@ void luv_on_timer(uv_timer_t* handle, int status) {
int before = lua_gettop(L);
lua_rawgeti(L, LUA_REGISTRYINDEX, ref->r);
+ // FIXME: PROPER ERROR HANDLER
lua_pushinteger(L, status);
luv_emit_event(L, "timeout", 1);
//lua_pop(L, 1); // remove the userdata
Please sign in to comment.
Something went wrong with that request. Please try again.