I really need to fix Zig's error handling on message send failure, it's so bad 😭
This commit is contained in:
Auguste Rame 2022-07-11 20:28:50 +02:00
parent acd57ddb16
commit 37f79c86fa
No known key found for this signature in database
GPG Key ID: 3A5E3F90DF2AAEFE
3 changed files with 4 additions and 8 deletions

View File

@ -32,8 +32,6 @@ for (const line of lines) {
const name = line.split(":")[0].trim();
const type = line.split(":")[1].split("=")[0].trim();
const defaultValue = line.split(":")[1].split("=")[1].trim().replace(",","");
// console.log(name, type, defaultValue);
console.log(`"zls.${name}": ${JSON.stringify({
"scope": "resource",

View File

@ -1756,6 +1756,7 @@ fn initializeHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req:
fn registerCapability(arena: *std.heap.ArenaAllocator, method: []const u8) !void {
// NOTE: stage1 moment occurs if we dont do it like this :(
// long live stage2's not broken anon structs
logger.debug("Dynamically registering method '{s}'", .{method});
const id = try std.fmt.allocPrint(arena.allocator(), "register-{s}", .{method});
@ -1778,8 +1779,6 @@ fn registerCapability(arena: *std.heap.ArenaAllocator, method: []const u8) !void
.params = respp,
};
std.log.info("AAAAA {s}", .{req});
try send(arena, req);
}
@ -2241,10 +2240,8 @@ fn processJsonRpc(arena: *std.heap.ArenaAllocator, parser: *std.json.Parser, jso
else => types.RequestId{ .Integer = 0 },
} else types.RequestId{ .Integer = 0 };
if (id == .String and std.mem.startsWith(u8, id.String, "register")) {
logger.info("INFO!!! {s}", .{json});
if (id == .String and std.mem.startsWith(u8, id.String, "register"))
return;
}
if (id == .String and std.mem.eql(u8, id.String, "i_haz_configuration")) {
logger.info("Setting configuration...", .{});

View File

@ -66,7 +66,7 @@ const Server = struct {
const rest = response_bytes[json_fmt.len..];
const id_end = std.mem.indexOfScalar(u8, rest, ',') orelse return error.InvalidResponse;
const id = try std.fmt.parseInt(u32, rest[0..id_end], 10);
const id = std.fmt.parseInt(u32, rest[0..id_end], 10) catch continue;
if (id != self.request_id) {
continue;
@ -83,6 +83,7 @@ const Server = struct {
}
}
}
fn extractError(msg: []const u8) !void {
const log_request =
\\"method":"window/logMessage","params":{"type":