public ErrorResponse(final String message) { super(); this.message = message; exception = new BasicException(message); }
@Override public BigDecimal deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { try { return delegate.deserialize(jsonParser, deserializationContext); } catch (Exception e) { throw new BasicException("documentGrid.validate.field.error.invalidNumericFormat"); } }
public void delete(Long id) { DataDefinition dataDefinition = getActionForPlannedEventDD(); try { dataDefinition.delete(id); } catch (IllegalStateException exc) { throw new BasicException( translationService.translate("actionsGrid.notification.entityInUse", LocaleContextHolder.getLocale())); } }
throw new BasicException(errors.stream().collect(Collectors.joining("\n")));
private void updateActionForPlannedEvent(DataDefinition dataDefinition, Entity actionForPlannedEvent, ActionForPlannedEventDTO actionForPlannedEventDTO) { actionForPlannedEvent.setField(ActionForPlannedEventFields.RESPONSIBLE_WORKER, getWorkerId(actionForPlannedEventDTO.getResponsibleWorker())); actionForPlannedEvent.setField(ActionForPlannedEventFields.ACTION, getActionId(actionForPlannedEventDTO.getAction())); actionForPlannedEvent.setField(ActionForPlannedEventFields.DESCRIPTION, actionForPlannedEventDTO.getDescription()); actionForPlannedEvent.setField(ActionForPlannedEventFields.PLANNED_EVENT, actionForPlannedEventDTO.getPlannedEvent()); actionForPlannedEvent.setField(ActionForPlannedEventFields.REASON, actionForPlannedEventDTO.getReason()); actionForPlannedEvent.setField(ActionForPlannedEventFields.STATE, actionForPlannedEventDTO.getState()); actionForPlannedEvent = dataDefinition.save(actionForPlannedEvent); if (!actionForPlannedEvent.isValid()) { StringBuilder errors = new StringBuilder(); errors.append(actionForPlannedEvent.getGlobalErrors().stream() .map(error -> translationService.translate(error.getMessage(), LocaleContextHolder.getLocale())) .collect(Collectors.joining("\n"))); if (errors.length() > 0) { errors.append("\n"); } errors.append(actionForPlannedEvent.getErrors().entrySet().stream() .map(entry -> translationService.translate( "cmmsMachineParts.actionForPlannedEvent." + entry.getKey() + ".label", LocaleContextHolder.getLocale()) + " - " + translationService.translate(entry.getValue().getMessage(), LocaleContextHolder.getLocale())) .collect(Collectors.joining("\n"))); throw new BasicException(errors.toString()); } }