我使用的Restlet版本2.0.15MyStatusService抛出异常
我采取的是在飞行中产生潜在的巨大的zip文件是 通过REST客户端下载的服务。在生成此文件时,可能会发生错误,并且在我想给客户端提供有意义的错误响应时。
我的设置包括:
In the main, an instance of Application is constructed, and the Component.setStatusService(StatusService) and
Application.setStatusSevice(StatusService) are invoked with MyStatusService (Extends StatusService)
and, and MyStatusService overrides:
public Representation getRepresentation(Status status, Request request, Response response) {
public Status getStatus(Throwable throwable, Request request, Response response) {
public Status getStatus(Throwable throwable, UniformResource resource) {
...
When I handle the GET request from the client, I set the entity in the response
(Response.setEntity(Representation) with MyRepresentation which extends OutputRepresentation.
The MyRepresentation class overrides the method:
public void write(WritableByteChannel writableChannel)
which calls the overridden method:
public void write(OutputStream outputStream)
which does the work of generating the zip file.
当我运行它,会发生以下情况:
ServerCall.sendRespo NSE(响应)调用 - >
ServerCall.writeResp onseBody(Representat ion,WritableChannel,OutputStream) - > calls
MyRepresentation(延伸OutputRepresentation).WRITE(OutputStream中)
指找到(如预期)的一个问题与(有意坏用于测试的原因)请求, 并想给所述客户端的有意义的反应。所以,它抛出一个异常(它应该是一个ResourceException,或任何异常?),这是陷入
ServerAdapter.commit(HttpResponse)
,但在这之后,则不会调用在MyStatusService任何方法制成的,所以客户端不 得到一个有意义的消息,只有500个状态。
有没有一种方法可以控制客户的状态(理想情况下提供信息性消息)?
感谢任何信息,
- 吉姆