Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forceful sandboxing of handler in Route.handledIgnoreParams makes it impossible to do error introspection in Handler transformers. #3228

Open
notxcain opened this issue Dec 3, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@notxcain
Copy link

notxcain commented Dec 3, 2024

Describe the bug

Given the routes

val routes = Routes(
  Method.POST / Root / "fail""-> Handler.fromZIO(ZIO.dieMessage("Defect"))
)

and a transformer

def logDefects[A](handle: Handler[A, Response, Request, Response]): Handler[A, Response, Request, Response] =   
  handler { (req: Request) =      
    handle(req).catchAllDefect { e =>
        ZIO
          .logErrorCause("Application defect", Cause.die(e))
          .as(Response.internalServerError("Something went wrong"))
    }
   }

A POST /fail to routes.transform(logDefects) never logs the "Application defect" message.

Should sandboxing happen during the Server#install?

@notxcain notxcain added the bug Something isn't working label Dec 3, 2024
@jgranstrom
Copy link
Contributor

@notxcain this might be related #2725, regarding error introspection in general

@notxcain notxcain changed the title Forcefully sandboxing of handler in Route.handledIgnoreParams makes it impossible to do error introspection in Handler transformers. Forceful sandboxing of handler in Route.handledIgnoreParams makes it impossible to do error introspection in Handler transformers. Dec 3, 2024
@notxcain
Copy link
Author

notxcain commented Dec 3, 2024

The real reason is I'd like to see my defects in logs. I'm not sure how to achieve that using the existing ZIO HTTP DSL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants