<commit_before>package com.sequenceiq.cloudbreak.shell.transformer;

import org.springframework.stereotype.Component;

@Component
public class ExceptionTransformer {

    public RuntimeException transformToRuntimeException(Exception e) {
        return new RuntimeException(e.getMessage());
    }

    public RuntimeException transformToRuntimeException(String errorMessage) {
        return new RuntimeException(errorMessage);
    }
}<commit_msg>CLOUD-47839 fixed show the real error (#1479)<commit_after>package com.sequenceiq.cloudbreak.shell.transformer;

import java.io.IOException;

import javax.inject.Inject;
import javax.ws.rs.ClientErrorException;

import org.springframework.stereotype.Component;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

@Component
public class ExceptionTransformer {

    @Inject
    private ObjectMapper objectMapper;

    public RuntimeException transformToRuntimeException(Exception e) {
        if (e instanceof ClientErrorException) {
            if (((ClientErrorException) e).getResponse() != null && ((ClientErrorException) e).getResponse().hasEntity()) {
                String response = ((ClientErrorException) e).getResponse().readEntity(String.class);
                try {
                    JsonNode message = objectMapper.readTree(response).get("message");
                    return new RuntimeException(message.asText());
                } catch (IOException ex) {
                    return new RuntimeException(response);
                }
            }
        }
        return new RuntimeException(e.getMessage());
    }

    public RuntimeException transformToRuntimeException(String errorMessage) {
        return new RuntimeException(errorMessage);
    }
}
{'fraction_non_alphanumeric': 0.08860045146726862, 'fraction_numerical': 0.005079006772009029, 'mean_word_length': 3.399503722084367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2148582', 'n_tokens_mistral': 443, 'n_tokens_neox': 417, 'n_words': 91}