Skip to content

Commit

Permalink
Unify CatchAllExceptionMapper
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
  • Loading branch information
jbescos committed Dec 14, 2023
1 parent a4e968a commit 76e6609
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 157 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.IntStream;

import io.helidon.microprofile.server.CatchAllExceptionMapper;
import io.helidon.microprofile.testing.junit5.AddBean;
import io.helidon.microprofile.testing.junit5.HelidonTest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import io.helidon.lra.coordinator.client.CoordinatorClient;
import io.helidon.lra.coordinator.client.PropagatedHeaders;
import io.helidon.microprofile.config.ConfigCdiExtension;
import io.helidon.microprofile.lra.resources.CatchAllExceptionMapper;
import io.helidon.microprofile.lra.resources.CdiNestedCompleteOrCompensate;
import io.helidon.microprofile.lra.resources.CommonAfter;
import io.helidon.microprofile.lra.resources.DontEnd;
Expand All @@ -47,6 +46,7 @@
import io.helidon.microprofile.lra.resources.StartAndAfter;
import io.helidon.microprofile.lra.resources.Timeout;
import io.helidon.microprofile.lra.resources.Work;
import io.helidon.microprofile.server.CatchAllExceptionMapper;
import io.helidon.microprofile.server.JaxRsCdiExtension;
import io.helidon.microprofile.server.ServerCdiExtension;
import io.helidon.microprofile.testing.junit5.AddBean;
Expand Down Expand Up @@ -95,7 +95,7 @@
@AddExtension(CdiComponentProvider.class)
// LRA client
@AddExtension(LraCdiExtension.class)
// Test resources
// resources
@AddBean(CatchAllExceptionMapper.class)
@AddBean(JaxRsCompleteOrCompensate.class)
@AddBean(NonJaxRsCompleteOrCompensate.class)
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.regex.Pattern;
import java.util.stream.IntStream;

import io.helidon.microprofile.server.CatchAllExceptionMapper;
import io.helidon.microprofile.testing.junit5.AddBean;
import io.helidon.microprofile.testing.junit5.AddConfig;
import io.helidon.microprofile.testing.junit5.HelidonTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.helidon.integrations.micrometer.cdi;
package io.helidon.microprofile.server;

import java.lang.System.Logger.Level;

Expand All @@ -28,16 +28,25 @@
import jakarta.ws.rs.ext.Provider;

/**
* Default mapper for exceptions that are not caught.
* Mapper for exceptions that are not caught.
*
* It is not configured by default in Helidon but it is provided for explicit usage.
*/
@Provider
@Priority(5000)
public class CatchAllExceptionMapper implements ExceptionMapper<Exception> {

private static final System.Logger LOGGER = System.getLogger(CatchAllExceptionMapper.class.getName());

@Context
private ServerRequest serverRequest;

/**
* Default empty constructor.
*/
public CatchAllExceptionMapper() {
}

@Override
public Response toResponse(Exception exception) {
serverRequest.context().register("unmappedException", exception);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package io.helidon.microprofile.metrics.tck;

import io.helidon.microprofile.server.CatchAllExceptionMapper;

import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.spi.BeforeBeanDiscovery;
import jakarta.enterprise.inject.spi.Extension;
Expand Down

0 comments on commit 76e6609

Please sign in to comment.