@ExceptionHandler({HalException.class}) @ResponseBody public DaemonResponse<Void> handleHalconfigException(HttpServletResponse response, HalException exception) { response.setStatus(exception.getResponseCode()); return new DaemonResponse<>(null, exception.getProblems()); } }
public DaemonResponse<Void> build() { ProblemSet result; try { stage.run(); update.run(); result = validate.get(); result.throwifSeverityExceeds(severity); } catch (HalException e) { revert.run(); clean.run(); throw e; } catch (Exception e) { log.error("Unknown exception encountered: ", e); revert.run(); clean.run(); throw e; } save.run(); clean.run(); return new DaemonResponse<>(null, result); } }
public DaemonResponse<List<String>> build() { try { update.run(); FieldOptions options = fieldOptionsResponse.get(); return new DaemonResponse<>(options.getOptions(), options.getProblemSet()); } catch (HalException e) { // This is OK, propagate the exception to the HalconfigExceptionHandler throw e; } catch (Exception e) { log.error("Unknown exception encountered: ", e); throw e; } } }
public DaemonResponse<List<String>> build() { try { FieldOptions options = fieldOptionsResponse.get(); return new DaemonResponse<>(options.getOptions(), options.getProblemSet()); } catch (HalException e) { // This is OK, propagate the exception to the HalconfigExceptionHandler throw e; } catch (Exception e) { log.error("Unknown exception encountered: ", e); throw e; } } }
public void failure(HalException e) { inFailedState(); fatalError = e; response = new DaemonResponse<>(null, e.getProblems()); }
public DaemonResponse<K> build() { if (buildResponse == null) { throw new IllegalArgumentException("No response provided to build"); } K responseBody; ProblemSet problemSet = new ProblemSet(); try { setup.run(); if (validateResponse != null) { problemSet = validateResponse.get(); } problemSet.throwifSeverityExceeds(severity); } catch (Exception e) { log.error("Unknown exception encountered: ", e); throw e; } try { responseBody = buildResponse.get(); } catch (HalException e) { // This is OK, propagate the exception to the HalconfigExceptionHandler e.getProblems().addAll(problemSet); throw e; } catch (Exception e) { log.error("Unknown exception encountered: ", e); throw e; } return new DaemonResponse<>(responseBody, problemSet); } }
public void failure(Exception e) { inFailedState(); fatalError = e; Problem problem = new ProblemBuilder(Problem.Severity.FATAL, "Unexpected exception: " + e).build(); response = new DaemonResponse<>(null, new ProblemSet(problem)); }
U responseBody = base; ProblemSet problemSet = new ProblemSet(); DaemonResponse<U> response = new DaemonResponse<>(responseBody, problemSet);