private static ErrorDto getErrorDtoOrNull()

in src/main/java/com/epam/aidial/auth/helper/error/ExceptionToErrorDtoConverter.java [18:34]


    private static ErrorDto getErrorDtoOrNull(Throwable ex) {
        if (ex instanceof WebApplicationException) {
            final WebApplicationException wae = (WebApplicationException) ex;
            Object entry = wae.getResponse().getEntity();

            if (entry instanceof ErrorDto) {
                return (ErrorDto) entry;
            }
        }
        final Throwable cause = ex.getCause();

        if (cause != null && cause != ex) {
            return getErrorDtoOrNull(cause);
        }

        return null;
    }