|
8 | 8 | package org.seedstack.seed.rest.internal.exceptionmapper; |
9 | 9 |
|
10 | 10 | import org.seedstack.seed.Application; |
11 | | -import org.seedstack.seed.core.Seed; |
12 | 11 | import org.seedstack.seed.rest.RestConfig; |
13 | 12 | import org.seedstack.shed.exception.BaseException; |
14 | 13 | import org.slf4j.Logger; |
@@ -41,29 +40,28 @@ public InternalErrorExceptionMapper(Application application) { |
41 | 40 | @Override |
42 | 41 | public Response toResponse(Exception exception) { |
43 | 42 | String uuid = UUID.randomUUID().toString(); |
44 | | - BaseException translatedException = Seed.translateException(exception); |
45 | | - LOGGER.error(buildServerMessage(uuid, translatedException), translatedException); |
| 43 | + LOGGER.error(buildServerMessage(uuid, exception), exception); |
46 | 44 | return Response.status(Response.Status.INTERNAL_SERVER_ERROR) |
47 | | - .entity(buildUserMessage(uuid, translatedException)) |
| 45 | + .entity(buildUserMessage(uuid, exception)) |
48 | 46 | .build(); |
49 | 47 | } |
50 | 48 |
|
51 | | - private String buildUserMessage(String uuid, BaseException baseException) { |
| 49 | + private String buildUserMessage(String uuid, Exception exception) { |
52 | 50 | StringBuilder sb = new StringBuilder(16384); |
53 | 51 | sb.append("Internal server error [").append(uuid).append("]"); |
54 | 52 | if (exceptionMappingConfig.isDetailedUserMessage()) { |
55 | | - sb.append(": ").append(baseException.getDescription()); |
| 53 | + sb.append(": ").append(exception instanceof BaseException ? ((BaseException) exception).getDescription() : exception.getMessage()); |
56 | 54 | } |
57 | 55 | return sb.toString(); |
58 | 56 | } |
59 | 57 |
|
60 | | - private String buildServerMessage(String uuid, BaseException baseException) { |
| 58 | + private String buildServerMessage(String uuid, Exception exception) { |
61 | 59 | StringBuilder sb = new StringBuilder(16384); |
62 | 60 | sb.append("JAX-RS request error [").append(uuid).append("] on ").append(request.getRequestURI()).append("\n"); |
63 | 61 | if (exceptionMappingConfig.isDetailedLog()) { |
64 | | - sb.append(baseException.toString()); |
| 62 | + sb.append(exception.toString()); |
65 | 63 | } else { |
66 | | - sb.append(baseException.getMessage()); |
| 64 | + sb.append(exception.getMessage()); |
67 | 65 | } |
68 | 66 | return sb.toString(); |
69 | 67 | } |
|
0 commit comments