Extending Throwable in Java

前端 未结 7 1367
长发绾君心
长发绾君心 2020-12-16 10:47

Java lets you create an entirely new subtype of Throwable, e.g:

public class FlyingPig extends Throwable { ... }

Now, very

7条回答
  •  情深已故
    2020-12-16 10:58

    The Play! framework uses something like this for request handling. The request processing goes through many layers (routing, middleware, controllers, template rendering) and at the final layer the rendered HTML is wrapped in a throwable and thrown, which the top most layer catches, unwraps and sends to the client. So none of the methods in the many layers involved need to explicitly return a response object, nor do they need to have a response object passed as argument to be propagated and modified.

    I am bit sketchy on details. You can look through the code of Play! framework for details.

提交回复
热议问题