diff --git a/generators/server/templates/src/main/java/package/web/rest/errors/ExceptionTranslator.java.ejs b/generators/server/templates/src/main/java/package/web/rest/errors/ExceptionTranslator.java.ejs index 974b05c2db27..34c6f8de8403 100644 --- a/generators/server/templates/src/main/java/package/web/rest/errors/ExceptionTranslator.java.ejs +++ b/generators/server/templates/src/main/java/package/web/rest/errors/ExceptionTranslator.java.ejs @@ -25,6 +25,8 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; <%_ if (databaseType !== 'no' && databaseType !== 'cassandra') { _%> import org.springframework.dao.ConcurrencyFailureException; +<%_ } _%> +<%_ if (databaseType !== 'no') { _%> import org.springframework.dao.DataAccessException; <%_ } _%> import org.springframework.http.ResponseEntity; @@ -206,7 +208,7 @@ _%> @Override public ProblemBuilder prepare(final Throwable throwable, final StatusType status, final URI type) { - + Collection activeProfiles = Arrays.asList(env.getActiveProfiles()); if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) { @@ -221,8 +223,7 @@ _%> .map(this::toProblem) .orElse(null)); } - <%_ if (databaseType !== 'no' && databaseType !== 'cassandra') { _%> - + <%_ if (databaseType !== 'no') { _%> if (throwable instanceof DataAccessException) { return Problem.builder() .withType(type) @@ -235,7 +236,6 @@ _%> .orElse(null)); } <%_ } _%> - if (containsPackageName(throwable.getMessage())) { return Problem.builder() .withType(type) @@ -265,4 +265,4 @@ _%> // This list is for sure not complete return StringUtils.containsAny(message, "org.", "java.", "net.", "javax.", "com.", "io.", "de.", "<%= packageName %>"); } -} +} \ No newline at end of file