-1
ExceptionMapper
の私の実装は以下のように見える例外を捕捉していない:私のREST APIでジャージーを
@Provider
public class CaptureUnhandledExceptions implements ExceptionMapper<Throwable>
{
private static final Logger LOGGER = LogFactory.getLogger(CaptureUnhandledExceptions.class);
@Override
public Response toResponse(Throwable exception)
{
LOGGER.error("Unhandled exception", exception);
ErrorMessage em = new ErrorMessage(50099, ExceptionUtils.getRootCause(exception).getMessage(),
exception.getMessage());
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(em).build();
}
}
、私は私のJSON
の体のためのパス誤った値をしようとしていますが、それは次の例外に
Can not deserialize value of type com.abccompany.model.ConnectionEndpoint$Binding from String "RandomValue: value not one of declared Enum instance names: [POST, REDIRECT]
at [Source: org.glassfish.jersey.me[email protected]3fce79f3; line: 16, column: 28] (through reference chain: com.abccompany.model.SpConnection["connection"]->com.abccompany.model.Connection["connectionendpoints"]->java.util.ArrayList[0]->com.abccompany.model.ConnectionEndpoint["endpointbinding"])
を投げています
私は何が欠けていますか?プロバイダをResourceConfig
に登録する必要がありますか?
アプリケーション
this.register(com.abccompany.utils.CaptureUnhandledExceptions.class);
で
this.register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class);
を追加しましたあなたのログファイルに「未処理の例外」を見たことがありますか?カスタム例外ハンドラクラスを登録する必要はありません。 – zappeeいいえ...私はちょうど私が何かが欠けていないことを確認するためにそれをした – yogsma
何かが起こるのを見るためにあなたの残りの方法で新しいException( "何かを言う...")を故意に投げてみてください。 – zappee