Skip to content

Commit b615174

Browse files
committed
Improve panic detail when unable to locate a function
1 parent 1c53ef1 commit b615174

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/root.zig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ comptime {
5050
}
5151
}
5252

53+
fn panicLocateFunction(name: []const u8) noreturn {
54+
@branchHint(.cold);
55+
std.debug.panic("Failed to locate function {s}", .{name});
56+
}
57+
5358
fn loadFunctions(dll: std.os.windows.HMODULE) void {
5459
inline for (comptime std.meta.fieldNames(ProxyFuncAddrs)) |field| {
55-
@field(proxy_func_addrs, field) = std.os.windows.kernel32.GetProcAddress(dll, field).?;
60+
@field(proxy_func_addrs, field) = std.os.windows.kernel32.GetProcAddress(dll, field) orelse {
61+
panicLocateFunction(field);
62+
};
5663
}
5764
}
5865

0 commit comments

Comments
 (0)