@@ -88,20 +88,13 @@ pub const ServerStatus = struct {
8888 start_time : i64 ,
8989 allocator : std.mem.Allocator ,
9090
91- pub fn init (allocator : std.mem.Allocator ) ServerStatus {
92- const protocols = std .ArrayList ([]const u8 ).initCapacity (allocator , 4 ) catch return ServerStatus {
93- .running = false ,
94- .uptime = 0 ,
95- .connections = 0 ,
96- .protocols_active = std .ArrayList ([]const u8 ).initCapacity (allocator , 0 ) catch unreachable ,
97- .start_time = 0 ,
98- .allocator = allocator ,
99- };
91+ pub fn init (allocator : std.mem.Allocator ) ! ServerStatus {
92+ const protocols = std .ArrayList ([]const u8 ).initCapacity (allocator , 4 );
10093 return ServerStatus {
10194 .running = false ,
10295 .uptime = 0 ,
10396 .connections = 0 ,
104- .protocols_active = protocols ,
97+ .protocols_active = try protocols ,
10598 .start_time = 0 ,
10699 .allocator = allocator ,
107100 };
@@ -127,7 +120,7 @@ pub const UnifiedApiServer = struct {
127120 const server = UnifiedApiServer {
128121 .allocator = allocator ,
129122 .config = config ,
130- .status = ServerStatus .init (allocator ),
123+ .status = try ServerStatus .init (allocator ),
131124 .registry = api .CommandRegistry .init (allocator ),
132125 .server_socket = null ,
133126 };
@@ -1056,7 +1049,7 @@ test "ServeConfig defaults" {
10561049}
10571050
10581051test "ServerStatus init" {
1059- var status = ServerStatus .init (std .testing .allocator );
1052+ var status = try ServerStatus .init (std .testing .allocator );
10601053 defer status .deinit ();
10611054
10621055 try std .testing .expect (! status .running );
0 commit comments