Skip to content

Commit

Permalink
Merge pull request #12830 from gmarziou/v6.x_maintenance
Browse files Browse the repository at this point in the history
Exclude translation of DataAccessException when there's no database
  • Loading branch information
pascalgrimaud authored Oct 24, 2020
2 parents d0a97e3 + 74e0739 commit e15092e
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -206,7 +208,7 @@ _%>

@Override
public ProblemBuilder prepare(final Throwable throwable, final StatusType status, final URI type) {

Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());

if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
Expand All @@ -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)
Expand All @@ -235,7 +236,6 @@ _%>
.orElse(null));
}
<%_ } _%>

if (containsPackageName(throwable.getMessage())) {
return Problem.builder()
.withType(type)
Expand Down Expand Up @@ -265,4 +265,4 @@ _%>
// This list is for sure not complete
return StringUtils.containsAny(message, "org.", "java.", "net.", "javax.", "com.", "io.", "de.", "<%= packageName %>");
}
}
}

0 comments on commit e15092e

Please sign in to comment.