@Override public String toString() { return this.getClass().getName() + " [" + "message='" + getMessage() + '\'' + ", errorCode=" + errorCode + ", statusCode=" + statusCode + ", description='" + description + '\'' + ", href=" + href + ", dittoHeaders=" + dittoHeaders + ']'; }
@Override public String toString() { return this.getClass().getName() + " [" + "message='" + getMessage() + '\'' + ", errorCode=" + errorCode + ", statusCode=" + statusCode + ", description='" + description + '\'' + ", href=" + href + ", dittoHeaders=" + dittoHeaders + ']'; }
private void handleException(final DittoRuntimeException exception) { if (exception instanceof ThingNotAccessibleException) { log.info("Thing no longer accessible - deleting the Thing from search index: {}", exception.getMessage()); deleteThingFromSearchIndex(); } else if (exception instanceof PolicyNotAccessibleException) { log.info("Policy no longer accessible - deleting the Thing from search index: {}", exception.getMessage()); deleteThingFromSearchIndex(); } else { log.error("Received exception while trying to sync thing <{}>: {} {}", thingId, exception.getClass().getSimpleName(), exception.getMessage()); triggerSynchronization(); } }
private Optional<ExternalMessage> mapToExternalMessage(final Signal<?> signal) { try { return processor.process(signal); } catch (final DittoRuntimeException e) { log.info("Got DittoRuntimeException during processing Signal: {} - {}", e.getMessage(), e.getDescription().orElse("")); } catch (final Exception e) { log.warning("Got unexpected exception during processing Signal: {}", e.getMessage()); } return Optional.empty(); }
private Optional<ExternalMessage> mapToExternalMessage(final Signal<?> signal) { try { return processor.process(signal); } catch (final DittoRuntimeException e) { log.info("Got DittoRuntimeException during processing Signal: {} - {}", e.getMessage(), e.getDescription().orElse("")); } catch (final Exception e) { log.warning("Got unexpected exception during processing Signal: {}", e.getMessage()); } return Optional.empty(); }
private <T extends Command> void catchDittoRuntimeException(final Consumer<T> consumer, final T command) { try { consumer.accept(command); } catch (final InvalidRqlExpressionException | InvalidOptionException e) { logger.warning("Error when creating PolicyRestrictedSearchAggregation from Command: {}", e.getMessage()); getSender().tell(e, getSelf()); } }
private <T extends Command> void catchDittoRuntimeException(final Consumer<T> consumer, final T command) { try { consumer.accept(command); } catch (final InvalidRqlExpressionException | InvalidOptionException e) { logger.warning("Error when creating PolicyRestrictedSearchAggregation from Command: {}", e.getMessage()); getSender().tell(e, getSelf()); } }
private void logDittoRuntimeException(final DittoRuntimeException exception) { LogUtil.enhanceLogWithCorrelationId(log, exception); final String msgTemplate = "Got DittoRuntimeException '{}' when command via AMQP was processed: {}"; log.info(msgTemplate, exception.getErrorCode(), exception.getMessage()); }
private <T extends Command> void catchDittoRuntimeException(final Consumer<T> consumer, final T command) { try { consumer.accept(command); } catch (final InvalidFilterException | InvalidOptionException e) { logger.warning("Error when creating PolicyRestrictedSearchAggregation from Command: {}", e.getMessage()); getSender().tell(e, getSelf()); } }
private CompletionStage<Status.Status> testMessageMappingProcessor(@Nullable final MappingContext mappingContext) { try { // this one throws DittoRuntimeExceptions when the mapper could not be configured MessageMappingProcessor.of(connectionId(), mappingContext, getContext().getSystem(), log); return CompletableFuture.completedFuture(new Status.Success("mapping")); } catch (final DittoRuntimeException dre) { log.info("Got DittoRuntimeException during initialization of MessageMappingProcessor: {} {} - desc: {}", dre.getClass().getSimpleName(), dre.getMessage(), dre.getDescription().orElse("")); getSender().tell(dre, getSelf()); return CompletableFuture.completedFuture(new Status.Failure(dre)); } }
private <T extends Command> void catchDittoRuntimeException(final Consumer<T> consumer, final T command) { try { consumer.accept(command); } catch (final InvalidRqlExpressionException | InvalidOptionException e) { LogUtil.enhanceLogWithCorrelationId(logger, command); logger.info("Error when creating Query from Command: {}", e.getMessage()); getSender().tell(e, getSelf()); } }
private <T extends Command> void catchDittoRuntimeException(final Consumer<T> consumer, final T command) { try { consumer.accept(command); } catch (final InvalidFilterException | InvalidOptionException e) { LogUtil.enhanceLogWithCorrelationId(logger, command); logger.info("Error when creating Query from Command: {}", e.getMessage()); getSender().tell(e, getSelf()); } }
private CompletionStage<Status.Status> testMessageMappingProcessor(@Nullable final MappingContext mappingContext) { try { // this one throws DittoRuntimeExceptions when the mapper could not be configured MessageMappingProcessor.of(connectionId(), mappingContext, getContext().getSystem(), log); return CompletableFuture.completedFuture(new Status.Success("mapping")); } catch (final DittoRuntimeException dre) { log.info("Got DittoRuntimeException during initialization of MessageMappingProcessor: {} {} - desc: {}", dre.getClass().getSimpleName(), dre.getMessage(), dre.getDescription().orElse("")); getSender().tell(dre, getSelf()); return CompletableFuture.completedFuture(new Status.Failure(dre)); } }
private void logDittoRuntimeException(final DittoRuntimeException dre) { if (dre.getDittoHeaders().getCorrelationId().isPresent()) { LogUtil.enhanceLogWithCorrelationId(logger, dre); } logger.info("DittoRuntimeException '{}': {}", dre.getErrorCode(), dre.getMessage()); }
private <T extends Command> void catchDittoRuntimeException(final Consumer<T> consumer, final T command) { try { consumer.accept(command); } catch (final InvalidRqlExpressionException | InvalidOptionException e) { LogUtil.enhanceLogWithCorrelationId(logger, command); logger.info("Error when creating Query from Command: {}", e.getMessage()); getSender().tell(e, getSelf()); } }
public DittoRuntimeAssert hasMessage(final String expectedMessage) { isNotNull(); final String actualMessage = actual.getMessage(); assertThat(actualMessage) // .overridingErrorMessage("Expected message of DittoRuntimeException to be \n<%s> but it was \n<%s>", expectedMessage, actualMessage) // .isEqualTo(expectedMessage); return this; }
private void handleDittoRuntimeException(final ActorRef delegateActor, final DittoRuntimeException cre) { LogUtil.enhanceLogWithCorrelationId(logger, cre.getDittoHeaders().getCorrelationId()); logger.info("Got 'DittoRuntimeException': {} {}", cre.getClass().getName(), cre.getMessage()); cre.getDittoHeaders().getCorrelationId().ifPresent(outstandingCommandCorrelationIds::remove); if (cre.getDittoHeaders().isResponseRequired()) { delegateActor.forward(cre, getContext()); } else { logger.debug("Requester did not require response (via DittoHeader '{}') - not sending one", DittoHeaderDefinition.RESPONSE_REQUIRED); } }
@Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final Predicate<JsonField> predicate = schemaVersion.and(thePredicate); final Predicate<JsonField> nonNullAndCustomDefined = predicate.and(JsonField.isValueNonNull()); final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder() .set(JsonFields.STATUS, statusCode.toInt(), nonNullAndCustomDefined) .set(JsonFields.ERROR_CODE, errorCode, nonNullAndCustomDefined) .set(JsonFields.MESSAGE, getMessage(), nonNullAndCustomDefined) .set(JsonFields.DESCRIPTION, description, nonNullAndCustomDefined) .set(JsonFields.HREF, href != null ? href.toString() : null, nonNullAndCustomDefined); appendToJson(jsonObjectBuilder, nonNullAndCustomDefined); return jsonObjectBuilder.build(); }
private void handleDittoRuntimeException(final DittoRuntimeException exception, final Map<String, String> dittoHeaders) { final ThingErrorResponse errorResponse = ThingErrorResponse.of(exception, DittoHeaders.newBuilder(exception.getDittoHeaders()) .putHeaders(dittoHeaders) .build()); enhanceLogUtil(exception); final String stackTrace = stackTraceAsString(exception); log.info("Got DittoRuntimeException '{}' when ExternalMessage was processed: {} - {}. StackTrace: {}", exception.getErrorCode(), exception.getMessage(), exception.getDescription().orElse(""), stackTrace); handleCommandResponse(errorResponse); }
private void handleDittoRuntimeException(final DittoRuntimeException exception, final Map<String, String> dittoHeaders) { final ThingErrorResponse errorResponse = ThingErrorResponse.of(exception, DittoHeaders.newBuilder(exception.getDittoHeaders()) .putHeaders(dittoHeaders) .build()); enhanceLogUtil(exception); final String stackTrace = stackTraceAsString(exception); log.info("Got DittoRuntimeException '{}' when ExternalMessage was processed: {} - {}. StackTrace: {}", exception.getErrorCode(), exception.getMessage(), exception.getDescription().orElse(""), stackTrace); handleCommandResponse(errorResponse); }