2017-08-30 138 views
0

我通過擴展jax-rs api的WebApplicationException類創建了自定義異常類。我在錯誤的輸入上拋出這個異常。WebApplicationException未顯示錯誤消息

public class RestException extends WebApplicationException { 

    public RestException(String message, Response.Status status) { 
     super(message, status); 
    } 


} 

當我在我的應用程序異常上面使用,這是正確的返回狀態代碼,但它沒有返回錯誤信息我在構造函數中設置。

如果我使用澤西而不是cxf,它顯示錯誤消息和狀態碼。對此有任何幫助....

回答

0

我通過更改如下面的RestException構造的簽名來擺脫該問題。

public class RestException extends WebApplicationException { 

    public RestException(String message, Response.Status status) { 
     super(Response.status(status).entity(message).type(MediaType.TEXT_PLAIN).build()); 
    } 


}