<commit_before>package net.stargraph.server;

import net.stargraph.StarGraphException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;

import javax.inject.Singleton;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

@Provider
@Singleton
public final class CatchAllExceptionMapper implements ExceptionMapper<Exception> {
    private Logger logger = LoggerFactory.getLogger(getClass());
    private Marker marker = MarkerFactory.getMarker("server");

    @Override
    public Response toResponse(Exception exception) {
        logger.error(marker, "Oops!", exception);
        if (exception instanceof StarGraphException) {
            return ResourceUtils.createAckResponse((StarGraphException) exception);
        }<commit_msg>fix: wrong exception handling for the jax-rs webapp erros.<commit_after>package net.stargraph.server;

import net.stargraph.StarGraphException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;

import javax.inject.Singleton;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

@Provider
@Singleton
public final class CatchAllExceptionMapper implements ExceptionMapper<Exception> {
    private Logger logger = LoggerFactory.getLogger(getClass());
    private Marker marker = MarkerFactory.getMarker("server");

    @Override
    public Response toResponse(Exception exception) {
        if (exception instanceof StarGraphException) {
            return ResourceUtils.createAckResponse((StarGraphException) exception);
        }

        if (exception instanceof WebApplicationException) {
            return ((WebApplicationException) exception).getResponse();
        }

        logger.error(marker, "Oops!", exception);
{'fraction_non_alphanumeric': 0.09344346928239546, 'fraction_numerical': 0.004130098089829634, 'mean_word_length': 4.7, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1922143', 'n_tokens_mistral': 530, 'n_tokens_neox': 530, 'n_words': 119}