@@ -132,6 +132,7 @@ const SearchResultsJSON = struct {
132
132
133
133
fn getId (req : * httpz.Request , res : * httpz.Response , send_body : bool ) ! ? u32 {
134
134
const id_str = req .param ("id" ) orelse {
135
+ log .warn ("missing id parameter" , .{});
135
136
if (send_body ) {
136
137
try writeErrorResponse (400 , error .MissingId , req , res );
137
138
} else {
@@ -140,6 +141,7 @@ fn getId(req: *httpz.Request, res: *httpz.Response, send_body: bool) !?u32 {
140
141
return null ;
141
142
};
142
143
return std .fmt .parseInt (u32 , id_str , 10 ) catch | err | {
144
+ log .warn ("invalid id parameter: {}" , .{err });
143
145
if (send_body ) {
144
146
try writeErrorResponse (400 , err , req , res );
145
147
} else {
@@ -151,6 +153,7 @@ fn getId(req: *httpz.Request, res: *httpz.Response, send_body: bool) !?u32 {
151
153
152
154
fn getIndex (ctx : * Context , req : * httpz.Request , res : * httpz.Response , send_body : bool ) ! ? * Index {
153
155
const index_name = req .param ("index" ) orelse {
156
+ log .warn ("missing index parameter" , .{});
154
157
if (send_body ) {
155
158
try writeErrorResponse (400 , error .MissingIndexName , req , res );
156
159
} else {
@@ -159,6 +162,7 @@ fn getIndex(ctx: *Context, req: *httpz.Request, res: *httpz.Response, send_body:
159
162
return null ;
160
163
};
161
164
const index = ctx .indexes .getIndex (index_name ) catch | err | {
165
+ log .warn ("error during getIndex: {}" , .{err });
162
166
if (err == error .IndexNotFound ) {
163
167
if (send_body ) {
164
168
try writeErrorResponse (404 , err , req , res );
@@ -243,6 +247,7 @@ fn writeErrorResponse(status: u16, err: anyerror, req: *httpz.Request, res: *htt
243
247
244
248
fn getRequestBody (comptime T : type , req : * httpz.Request , res : * httpz.Response ) ! ? T {
245
249
const content = req .body () orelse {
250
+ log .warn ("no body" , .{});
246
251
try writeErrorResponse (400 , error .NoContent , req , res );
247
252
return null ;
248
253
};
@@ -255,12 +260,14 @@ fn getRequestBody(comptime T: type, req: *httpz.Request, res: *httpz.Response) !
255
260
switch (content_type ) {
256
261
.json = > {
257
262
return json .parseFromSliceLeaky (T , req .arena , content , .{}) catch | err | {
263
+ log .warn ("json error: {}" , .{err });
258
264
try writeErrorResponse (400 , err , req , res );
259
265
return null ;
260
266
};
261
267
},
262
268
.msgpack = > {
263
269
return msgpack .decodeFromSliceLeaky (T , req .arena , content ) catch | err | {
270
+ log .warn ("msgpack error: {}" , .{err });
264
271
try writeErrorResponse (400 , err , req , res );
265
272
return null ;
266
273
};
0 commit comments