Skip to content

Commit

Permalink
Simplified error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
latenitefilms authored and cmsj committed Nov 12, 2024
1 parent ca91c17 commit fa58fd4
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions extensions/httpserver/libhttpserver.m
Original file line number Diff line number Diff line change
Expand Up @@ -583,13 +583,8 @@ static int httpserver_start(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L];
HSHTTPServer *server = getUserData(L, 1);

if (server.wsCallback != LUA_NOREF) {
NSError *error = nil;
if (![server start:&error]) {
[skin logError:[NSString stringWithFormat:@"hs.httpserver:start() Unable to start object: %@", error]];
}
else if (server.fn == LUA_NOREF) {
[skin logError:@"hs.httpserver:start() called with no callback set. You must call hs.httpserver:setCallback() first"];
if (server.fn == LUA_NOREF && server.wsCallback == LUA_NOREF) {
[skin logError:@"hs.httpserver:start() called with no callback set. You must call `hs.httpserver:setCallback()` or `hs.httpserver:websocket()` first."];
} else {
NSError *error = nil;
if (![server start:&error]) {
Expand Down

0 comments on commit fa58fd4

Please sign in to comment.