@Test public void handleErrorTest() { reset(clientRuntimeError); when(clientRuntimeError.getThrowable()).thenReturn(new DefinitionNotFoundException("Error", DEFINITION_ID)); diagramClientErrorHandler.handleError(clientRuntimeError, message -> Assert.assertEquals(ERROR_MESSAGE, message)); when(clientRuntimeError.getThrowable()).thenReturn(new RuntimeException()); when(clientRuntimeError.toString()).thenReturn("runtime"); diagramClientErrorHandler.handleError(clientRuntimeError, message -> Assert.assertEquals("runtime", message)); }
public void handleError(ClientRuntimeError error, Consumer<String> showError) { if (Objects.isNull(error)) { throw new RuntimeException("Error cannot be null"); } String message = null; if (error.getThrowable() instanceof DefinitionNotFoundException) { message = translationService.getValue(CoreTranslationMessages.DIAGRAM_LOAD_FAIL_UNSUPPORTED_ELEMENTS, ((DefinitionNotFoundException) error.getThrowable()).getDefinitionId()); } showError.accept(Objects.nonNull(message) ? message : error.toString()); }
DiagramClientErrorHandler extends ClientErrorHandler { public void handleError(ClientRuntimeError error, Consumer<String> showError) { if (Objects.isNull(error)) { throw new RuntimeException("Error cannot be null"); } String message = null; if (error.getThrowable() instanceof DefinitionNotFoundException) { message = translationService.getValue(CoreTranslationMessages.DIAGRAM_LOAD_FAIL_UNSUPPORTED_ELEMENTS, ((DefinitionNotFoundException) error.getThrowable()).getDefinitionId()); } showError.accept(Objects.nonNull(message) ? message : error.toString()); } }
DiagramClientErrorHandler extends ClientErrorHandler { public void handleError(ClientRuntimeError error, Consumer<String> showError) { if (Objects.isNull(error)) { throw new RuntimeException("Error cannot be null"); } String message = null; if (error.getThrowable() instanceof DefinitionNotFoundException) { message = translationService.getValue(CoreTranslationMessages.DIAGRAM_LOAD_FAIL_UNSUPPORTED_ELEMENTS, ((DefinitionNotFoundException) error.getThrowable()).getDefinitionId()); } showError.accept(Objects.nonNull(message) ? message : error.toString()); } @Inject  DiagramClientErrorHandler(final ClientTranslationService translationService); }
DiagramClientErrorHandler extends ClientErrorHandler { public void handleError(ClientRuntimeError error, Consumer<String> showError) { if (Objects.isNull(error)) { throw new RuntimeException("Error cannot be null"); } String message = null; if (error.getThrowable() instanceof DefinitionNotFoundException) { message = translationService.getValue(CoreTranslationMessages.DIAGRAM_LOAD_FAIL_UNSUPPORTED_ELEMENTS, ((DefinitionNotFoundException) error.getThrowable()).getDefinitionId()); } showError.accept(Objects.nonNull(message) ? message : error.toString()); } @Inject  DiagramClientErrorHandler(final ClientTranslationService translationService); void handleError(ClientRuntimeError error, Consumer<String> showError); }
DiagramClientErrorHandler extends ClientErrorHandler { public void handleError(ClientRuntimeError error, Consumer<String> showError) { if (Objects.isNull(error)) { throw new RuntimeException("Error cannot be null"); } String message = null; if (error.getThrowable() instanceof DefinitionNotFoundException) { message = translationService.getValue(CoreTranslationMessages.DIAGRAM_LOAD_FAIL_UNSUPPORTED_ELEMENTS, ((DefinitionNotFoundException) error.getThrowable()).getDefinitionId()); } showError.accept(Objects.nonNull(message) ? message : error.toString()); } @Inject  DiagramClientErrorHandler(final ClientTranslationService translationService); void handleError(ClientRuntimeError error, Consumer<String> showError);  }