Unexpected Behavior with Defects in HTTP Server Error Handling
Hi everyone! I ran into some unexpected behavior related to defects when using the HTTP server.
Inside one of my endpoint handlers, I call Effect.die with a ParseError — this error is not related to the client request, it's an internal server issue. I expected it to be treated as a server error, logged at the error level (via HttpMiddleware.logger), and return a 500 response.
However, what I actually get is a 400 Bad Request, and the log is only at the info level.
This doesn’t seem right to me. Am I correct in thinking that the only way to fix this is to write custom middleware for error handling? Though ideally, I wouldn’t need to handle these defects at all — I expect them to be treated as internal server errors and logged accordingly.
Inside one of my endpoint handlers, I call Effect.die with a ParseError — this error is not related to the client request, it's an internal server issue. I expected it to be treated as a server error, logged at the error level (via HttpMiddleware.logger), and return a 500 response.
However, what I actually get is a 400 Bad Request, and the log is only at the info level.
This doesn’t seem right to me. Am I correct in thinking that the only way to fix this is to write custom middleware for error handling? Though ideally, I wouldn’t need to handle these defects at all — I expect them to be treated as internal server errors and logged accordingly.
