|
19 | 19 | package org.finos.waltz.web; |
20 | 20 |
|
21 | 21 | import org.eclipse.jetty.http.HttpStatus; |
22 | | -import org.finos.waltz.service.DIConfiguration; |
23 | | -import org.finos.waltz.service.settings.SettingsService; |
24 | | -import org.finos.waltz.web.endpoints.Endpoint; |
25 | | -import org.finos.waltz.web.endpoints.api.StaticResourcesEndpoint; |
26 | | -import org.finos.waltz.web.endpoints.extracts.DataExtractor; |
27 | 22 | import org.finos.waltz.common.LoggingUtilities; |
28 | 23 | import org.finos.waltz.common.exception.DuplicateKeyException; |
29 | 24 | import org.finos.waltz.common.exception.InsufficientPrivelegeException; |
30 | 25 | import org.finos.waltz.common.exception.NotFoundException; |
31 | 26 | import org.finos.waltz.common.exception.UpdateFailedException; |
| 27 | +import org.finos.waltz.service.DIConfiguration; |
| 28 | +import org.finos.waltz.service.settings.SettingsService; |
| 29 | +import org.finos.waltz.web.endpoints.Endpoint; |
32 | 30 | import org.finos.waltz.web.endpoints.EndpointUtilities; |
| 31 | +import org.finos.waltz.web.endpoints.api.StaticResourcesEndpoint; |
| 32 | +import org.finos.waltz.web.endpoints.extracts.DataExtractor; |
33 | 33 | import org.jooq.exception.DataAccessException; |
| 34 | +import org.jooq.exception.NoDataFoundException; |
34 | 35 | import org.slf4j.Logger; |
35 | 36 | import org.slf4j.LoggerFactory; |
36 | 37 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; |
|
42 | 43 | import java.util.Map; |
43 | 44 | import java.util.TimeZone; |
44 | 45 |
|
45 | | -import static org.finos.waltz.web.WebUtilities.reportException; |
| 46 | +import static java.lang.String.format; |
46 | 47 | import static org.finos.waltz.common.DateTimeUtilities.UTC; |
47 | | -import static spark.Spark.*; |
| 48 | +import static org.finos.waltz.web.WebUtilities.reportException; |
| 49 | +import static spark.Spark.after; |
| 50 | +import static spark.Spark.before; |
| 51 | +import static spark.Spark.options; |
| 52 | +import static spark.Spark.port; |
48 | 53 |
|
49 | 54 | public class Main { |
50 | 55 |
|
@@ -144,6 +149,17 @@ private void registerExceptionHandlers() { |
144 | 149 | LOG); |
145 | 150 | }); |
146 | 151 |
|
| 152 | + EndpointUtilities.addExceptionHandler(NoDataFoundException.class, (e, req, res) -> { |
| 153 | + String message = "Not found exception" + e.getMessage(); |
| 154 | + LOG.error(message, e); |
| 155 | + reportException( |
| 156 | + HttpStatus.NOT_FOUND_404, |
| 157 | + "NO_DATA", |
| 158 | + message, |
| 159 | + res, |
| 160 | + LOG); |
| 161 | + }); |
| 162 | + |
147 | 163 | EndpointUtilities.addExceptionHandler(UpdateFailedException.class, (e, req, res) -> { |
148 | 164 | String message = "Update failed exception:" + e.getMessage(); |
149 | 165 | LOG.error(message, e); |
@@ -178,7 +194,7 @@ private void registerExceptionHandlers() { |
178 | 194 | }); |
179 | 195 |
|
180 | 196 | EndpointUtilities.addExceptionHandler(DataAccessException.class, (e, req, resp) -> { |
181 | | - String message = "Exception: " + e.getCause().getMessage(); |
| 197 | + String message = format("Data Access Exception: %s [%s]", e.getCause(), e.getClass().getName()); |
182 | 198 | LOG.error(message, e); |
183 | 199 | reportException( |
184 | 200 | HttpStatus.BAD_REQUEST_400, |
|
0 commit comments